• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 83
  • Last Modified:


The gui in the smtp send mail task doesn't have a way to add the username and password.

What am I missing?
2 Solutions
Pawan KumarDatabase ExpertCommented:
It does not have username and password. Chk below-

Mail Page is a place where you specify most of the configuration for your Send Mail Task.

When you create an SMTP connection manager, a dialog box similar as shown below will come up. Here you specify a meaningful name and a small description for this SMTP connection manager and then you specify the SMTP Server.

The SMTP connection manager supports only anonymous authentication and Windows authentication. It does not support basic authentication. Check "Enable Secure Socket Layer (SSL)" option if you want to encrypt communication using Secure Sockets Layer (SSL) while sending e-mail messages.

One thing to note here is if you execute your package interactively from BIDS it uses the security context of the currently logged on user, whereas if you schedule it by executing a SQL Server Agent Job then it uses the account under which SQL Server Agent is running to connect to the SMTP host.
Arifhusen AnsariBusiness Intelligence AnalystCommented:
SMTP send mail task is not that much useful in ssis.
Rather i would suggest to use custom code to send a mail.

if provide the lots of flexibility.

You should you script task for the same.

Below is the code.

I have use this code in one of my solution and just modified some of the line to explain you.
So please ignore and syntax issues.

Hope it will help you.

public void Main()
            // TODO: Add your code here
            MailMessage mail = new MailMessage();
            string FilePath = Dts.Variables["ErrogLogFileFullPath"].Value.ToString();
            string ErrorPackageDetails = Dts.Variables["ErrorPackageDetails"].Value.ToString();
            string[] ErrorPackageDetailsArray = ErrorPackageDetails.Split(',');
            string SMTPServer = Dts.Variables["SMTPServer"].Value.ToString();
            string serverName = Dts.Variables["ServerName"].Value.ToString();
            int SMTPPort = Int32.Parse(Dts.Variables["SMTPPort"].Value.ToString());
            string EmailReceipientString = Dts.Variables["EmailRecipient"].Value.ToString();
            string[] EmailReceipientArray = EmailReceipientString.Split(',');
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com", 465);
            string SenderEmail = <email id used to send mail>
            string SenderEmailPass = <email password used to send mail>
            SmtpServer.Credentials = new System.Net.NetworkCredential(SenderEmail, SenderEmailPass);
            SmtpServer.EnableSsl = true;
            SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
            SmtpServer.Timeout = 30000;
            Attachment attch = new Attachment(FilePath);
            mail.From = new MailAddress(SenderEmail);
            mail.Subject = GenerateMailSubject(ErrorPackageDetailsArray, serverName);
            mail.Body = GenerateMailBody(ErrorPackageDetailsArray);
            mail.Priority = MailPriority.High;
            foreach (string EmailReceipient in EmailReceipientArray)
			// This is the code to add the receipients 
            Dts.TaskResult = (int)ScriptResults.Success;

Open in new window


Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now