–Namespaces
using System.Net;
using System.Net.Mail;
public void Main()
{
// TODO: Add your code here
            string EmailSender = “senter@gmail.com”;
            string EmailRecipient = “recipient@gmail.com”;
            string EmailServer = “smtp.gmail.com“;
            string EmailBody = “Hello SSIS”;
 
            Attachment myAttachment = new Attachment(“C:\\Users\\\H007\\Desktop\\Test.txt”);
            MailMessage myhtmlMessage = new MailMessage(EmailSender,EmailRecipient,”Result of import”, EmailBody);
            SmtpClient mysmtpclient =  new SmtpClient(EmailServer,587);
            mysmtpclient.EnableSsl = true;
            System.Net.NetworkCredential crediantials =  new NetworkCredential(EmailSender,“Password”);
            mysmtpclient.UseDefaultCredentials = false;
            mysmtpclient.Credentials = crediantials;
            myhtmlMessage.Attachments.Add(myAttachment);
            mysmtpclient.Send(myhtmlMessage);
Dts.TaskResult = (int)ScriptResults.Success;
}
        #region ScriptResults declaration
        /// <summary>
        /// This enum provides a convenient shorthand within the scope of this class for setting the
        /// result of the script.
        ///
        /// This code was generated automatically.
        /// </summary>
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion
}

Leave a Reply

Post Navigation