Solved - SSIS - Send mail on error task sends multiple mails - ssis

I build a SSIS-Package to import data from an excel-file. As the excel file is required to have a certain scheme, it fails sometimes if the person creating the file does not stick to the scheme. For this case, i want to send a mail to this person, informing about the fail. I tried different methods but the send mail task always sends 5 to 6 mails instead of one.
The basic structure of my package is this:
The mail task is a simple "Send Mail Task" via SMTP Connection Manager and without attachements, only a message.
Previous approaches are:
With the Event Handler: Settings i tried are Event Handler: OnError and Executable: Whole Package level, on the foreach loop container and on the single "Import File" Task, as this is the one that fails.
In the control flow: I conneted the mail task on failure with the loop container and also with the single import file task:
I also played with the "Delay Validation"-setting in the properties, setting it on true for the loop container and also the import file task.
Where is the mistake i make and how can i fix the package to send only one mail instead of 5-6? Thanks in advance!
Update: The Problem kinda solved itself. I changed from a send mail task to a script task to send a mail with a logfile, this worked perfectly. I also changed the mail_from in the send mail task from a mail-container to a single mail, and this also solved the problem. After that, i changed again to the mail-container and it also works how it should. Seems to be a bug. Thanks all.

Related

Why my Soffid JSON REST Web Services Connector does not update an object in the target system?

I am trying to connect my Soffid 3 server with our custom web application named Schrift. I am using а JSON REST Web Services Connector for this purpose. I added REST Web service plugin and then configured an agent with JSON/XML/SOAP Rest webservice type.
Loading of objects is working fine. My REST connector connects to the web service successfully and gets data of the accounts.
The problem is when I am trying to update some data (for example, I am trying to lock an account), nothing happens. And unfortunately I don't know what should be happening. When should REST connector send updated data to the managed system and in which way? I didn't find any log entries saying that REST connector was trying to update an object on managed system. Maybe I did smth wrong or missed something.
I would appreciate for any help. I can post any conf or log details if you need.
Update#1
(I did some investigation after the first answer)
I checked the agent settings: Read only and Manual account creation are set to no
The account was set to unmanaged type, but I succeeded in changing its type to shared and then to single without getting an error. Now it is set to single
The task queue is empty.
Also I've checked that update method is present and update properties are set correctly. updateParams is not set (it means that all attributes should be sent to the managed system).
But when I change status of the account (from Enable to Disable), nothing happens.
In the console log I can see only these lines
14-Sep-2021 13:26:29.708 INFO [BPM-Scheduler:192.168.7.121:1] com.soffid.iam.bpm.job.JobExecutorThread.run No job to execute
When I manually run the task Analize impact for changes on Schrift, Execution log shows
Changes detected for accounts
=============================
NO CHANGE DETECTED
Changes detected for roles
=============================
NO CHANGE DETECTED
Update#2
After many attempts I made some progress. Now when I make some changes in the account, the task named UpdateAccount baklykov#irf.com.ua#Schrift appears, but runs with an error.
At first it was 415 Unsupported Media Type error as I wrote in comments, but now it looks a little different
Throws exception updating object : Extensible object [type = account]
EmployeeEmail: baklykov#irf.com.ua
IsLockedOut: true (log truncated) ...
caused by Unexpected response, Content-Type: null
Update#3
I found out that soffid's request for updating the object was in improper format (all the parameters were passed in the html request instead of putting them in json body)
After researching I found a method's property called Encoding and set it to application/json value.
Now the parameters are passed in json body (that's what I need), but now the problem is that soffid puts all the parameters in json body, including the key parameter by which the object for updating should be determined. My guess this is the reason why the object in the target system is still not updated.
In other words my application expects a request like this:
https://myapp.mysite.com/api/v1/Soffid/Employees?EmployeeEmail=baklykov%40irf.com.ua :
{"EmployeeLastName":"Baklykov","EmployeeFirstName":"Ivan"}
but Soffid sends this:
https://myapp.mysite.com/api/v1/Soffid/Employees:
{"EmployeeLastName":"Baklykov","EmployeeFirstName":"Ivan","EmployeeEmail":"baklykov#irf.com.ua"}
The system should have created a UpdateAccount task in the task queue. Please, verify:
The task engine is in automatic mode. In read-only or manual mode, no task will be created.
If you are updating an account, check the account is not set as unmanaged. In that case, no tasks is created.
Finally, verify the task queue has not held the task up.
Have you checked the engine mode? Look at Main Menu > Administration > Configure Soffid > Integration engine > Smart engine settings
It should be set to automatic.

Send automatic emails from CSV attachment

Each day I receive an email with a CSV/excel attachment With a list of email addresses. I’d like to automatically take these addresses and mail an email template to all of them. The catch is, it has to be done on a work computer so I can’t download any additional programs to help with it. This will need to be done with native Windows apps. I’ve tried using VBA without success (I’m not well versed). Any help would be appreciated.
You can develop a VBA macro or COM add-in if you are going to distribute the solution to multiple machines. Basically, you need to handle the NewMailEx event of the Application class. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.
Private Sub Applicaition_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Set mai = Application.Session.GetItemFromID(strEntryId)
MsgBox mai.Subject
End Sub
In the event handler, you need to save the attached Excel file to the hard drive. Then you can automate Excel to open the file and read its content for creating a new item based on a template saved. Read more about these actions in the following articles:
How To: Create a new Outlook message based on a template
How To: Create and send an Outlook message programmatically
How To: Fill TO,CC and BCC fields in Outlook programmatically

Sending email notification on error using SSIS

I am currently implementing Send Email notification on error in my SSIS package. It currently works. Just want to check if this is the right way of doing it.
If you want to trigger your mail task when any error occurs, consider the "Event Handlers".
This SimpleTask article provides a very good overview of the event handlers
https://www.red-gate.com/simple-talk/sql/ssis/ssis-event-handlers-basics/
SSIS event handlers are the simplest means of turning an SSIS script into a reliable system that is auditable, reacts appropriately to error conditions, reports progress and allows instrumentation and monitoring your SSIS packages. They are easy to implement, and provide a great deal of flexibility.
Sample screen shot:
Using event handler provides some advantage - you need not connect each task's failure. The system will call your event handler for the error.
Also, note there are 2 event handlers of interest:
OnError
OnTaskFailed
https://learn.microsoft.com/en-us/sql/integration-services/integration-services-ssis-event-handlers
OnError event - This event is raised when an error occurs.
OnTaskFailed event - This event is raised by a task when it fails.
One thing to watch out for is that you event handler may be called multiple times depending on the number of errors.
I think there is no standard answer to this question. But here are some of the tips that I am be able to think of.
First, not very sure what kind of plain text you are trying to send out, if they do not have dynamic text body, you could put that send email task in the event handlers right to the Control flow, Data Flow... tab, and put that on error for specific tasks.
Second, I personally do not prefer to use Failure output, you may need to increase the number of MaximumErrorCount so that the package could executed successfully, but sometimes the real error might not be detected because together with error output, the total error numbers is still less than the threshold.
Third, if you are sending the same text, and you will schedule it as a job in SQL Server Agent, you could go to Notifications option page, set the Send Email, basically it will be informative.
Last but not least, the Send Mail task supports plain text only, not any formatting like email coded by html & CSS, if you need to take the formatting into consideration, that might not be your choice, you could use Script task using C# or creating html page by using XML statement from your SSMS and put into a stored procedure, then sent out the html by Database Mail, you will find this tool under Management folder in your SSMS.

ssis send mail task: Error: An error occurred with the following error message: "The operation has timed out."

SSIS package in question runs a series of stored procedures and fills 13 different excel files with results and sends those excel files to 13 different users in attachments. Package run stops with the message in the title of this question, sometime right in the middle of sending or for example today, on the 4th user. The files get created because I can see them in their directories so only the send mail task is failing. When I go back to visual studio and execute each send task manually, send task works fine even though sometime it still gives me the error yet, still sends the right file to the right person but not thru SSIS package run in SQL server... I tried to delay SMTP processes thinking that might be in the way (to 660000 miliseconds) but did not help. Has this happened to anybody?.. Thanks for all your answers in advance.
Here is the full message for a task that sent the e-mail with attachment regardless the error when task was manually executed...
[Send Mail Task] Error: An error occurred with the following error message: "The operation has timed out.".
Progress: The SendMail task is completed. - 100 percent complete
Task Send Mail Task for Inventory Reports 038 failed
Finished, 12:03:03 PM, Elapsed time: 00:00:00.655
I think I figured it out why this was happening. In case somebody / anybody is interested, here is what I think has happened.
I was trying to expand the timeout period thru a script task, playing with Threading.Thread.Sleep value but I neglected to do the same in my SMTP connection properties. When I changed the timeout value in properties for SMTP connection, error messages stopped coming :)
I wish I could post a picture to show you where exactly that property is located but my reputation failed me!.. :( (less than 10 points yet)
I am in the process of completing all of my changes then I will post again with final result hoping that will resolve all of my problems.
Thanks to all who showed interest.

How to control triggering of email for the same error in ssis using event handlers?

I am using ssis event handler to trigger an email whenever an error occured in the entire package(PACKAGE+ONEEROR). Here number of emails triggered is equal to number of errors generated.How can I restrict it to one mail eventhough the same error occured 10 times.
Please suggest....
You have a few options. The problem with setting an ONERROR email at the package level is that it will send an email for each error the package encounters. This gets ugly if you have a deep level transform fail, which will error as it fails back up to the package level.
I suggest that you either:
1) Setup ONERROR events at the task level and remove the package level event. Usually this will be good enough. Most tasks will only have one error to report. Be careful with Data Flows, they can act in a similar fashion as the package level events.
2) Setup some sort of advance logging. I’ve seen this done several ways. I’ve seen some people setup Script tasks to log the errors (at the task level) to a variable, and then send a final email containing the variable in the body (at control flow level). I have also seen people call stored procedures (at the task level and package level) for each error that occurs. The sproc would log errors to the DB and allow the package to continue on to the next step/container. The logged errors can then be dumped into a csv and emailed as an attachment.
If you like your current setup, you can try changing the error properties for each container/task. I haven't ever done this, but I do know you can change the way tasks handle errors! I don't like this option because you would possibly be missing errors (maybe? kind of guessing).
update From another solution - If you want to keep your current email ONERROR and simply prevent certain errors from "bubbling" up and sending emails, you can follow this link to learn how to gracefully handle errors. You could prevent certain tasks errors from reaching your ONERROR event at the package level. good luck.