Friday, July 17, 2015

Send Mail Task

Aim :-  This post  is written for those geeks who want to know the purpose of send mail task in SSIS.
Description :-  As the name suggests, Send Mail Task is used to send an automatic e-mail message from the SSIS package control flow. We can also configure ssis send mail task task at various event handlers. For example – If I have to do the huge data loading from the remote server to my local machine then this process may takes around five hours. But, I do not want to spend that much of timeto see the process when it ends and then notify to my client about the same. Rather than this, what i will do is that I will setup a “Send mail task”, which will tell me and as well as my client that the data loading process has been successfully completed or not. In below steps, we will see practical example of how we can approach this i.e. To send email notification message from SSIS package using send mail task component.

Practical – SSIS Send Mail Task

Step 1 :  Configure SMTP connection

  • Drag & drop Send Mail Task to the control flow. Double click on the task to configure it.
Send Mail Task in SSIS
  • In General tab you can provide Name and Description to SSIS send mail task.
  • Go to Mail tab, and choose “New Connection” from the drop down list of “SmtpConnection“. You can take reference from the below image.
Send Mail Task Editor in SSIS
  • Once you click on New Connection, a window will show up as the screenshot provided below.
  • In this SMTP connection Manager Editor window, you can fill up this with desired information and click on OK button.
  1. Name = SMTP connection manager.
  2. Description = Give any desired description (I left Description as blank).
  3. Smtp server = mail.abc.com
NOTE –  You can provide proper  SMTP server name. The name what I have mentioned above will not work for you as it is a dummy server name. Here, I am not showing mine original SMTP server name.
SMTP connection Manager Editor in SSIS

Step 2 :  Configuring Send Mail Task in SSIS

  • From :  Specify sender’s e-mail address.
  • To :  Specify receiver’s e-mail address. If you want to send the same e-mail to multiple persons then separate each mail id with semicolons (;).
  • Cc : Specify the e-mail addresses, multiple recipients emails are separated with semicolons, of individuals who also receive copies of the message.
  • Bcc :  Specify the e-mail addresses, multiple recipients emails are separated with semicolons, of individuals who receive blind carbon copies (Bcc) copies of the message.
  • Subject :  Provide a subject line for the e-mail message.
  • Message Source type :  Direct Input.
  • Message Source :  Provide the message text for the e-mail message.
  • Priority :  Set the priority level of the message. The task supports three priority levels :- normal, low and high.
  • Attachments :  If you want to send any attachments along with the mail, you can add here.
NOTE –  “To, Cc, and Bcc” lines are limited to 256 characters, each in accordance with Internet standards.
  • Below is the screenshot of window (with dummy fields) after configuring Send Mail Task. Finally, Click on OK button and Execute the SSIS package. Just go ahead and hit the Start debuggingbutton or directly you can press F5.
Configure Send Mail Task in SSIS
  • In the below picture you can clearly observe that the Send Mail Task has been executed successfully. Also, an e-mail has been delivered to the related person(s).
Send email using Send Mail Task in SSIS
Send email using Send Mail Task in SSIS
Successful execution of SSIS package brings us to the end of this post on Send Mail Task. There are many possibilities with usage of this ssis send mail task.  I hope above explanation helped you to learn basics of send mail task. Any queries or feedback in the form of comment below will be highly appreciated.