Hi @luis santaella ,
SSIS built-in Send Mail Task was created long time ago for SSIS 2005, was never updated since, and has many limitations:
- Doesn't allow an email in HTML format.
- Doesn't allow to specify port.
- Doesn't support username/password for authentication.
- Etc.
Please find below c# code that sends an email in HTML format. You can easily adjust it to add a retry functionality.
SSIS Script Task
void Main()
{
try
{
string smtpAddress = ...
int portNumber = ...
bool enableSSL = ...
bool UseDefaultCredentials = ...
string emailFrom = ...
string password = ...
string emailTo = ...
string subject = ...
string body = ...
XElement xhtml = XElement.Parse(@"<html>
<head>
<meta charset='iso-8859-1'/>
<style>p {margin-bottom:1.5em}
div {font-size: 12pt}</style>
</head>
<body>
<div>
<p>Dear *eName*, *lname*</p>
<p>Congratulations on your purchase of a new Home. We hope you have moved in and are beginning to enjoy all the luxury and style distinctive to a Home. We know you will be pleased with our continued commitment to your satisfaction.</p>
<p>Home professional construction staff built your home using quality products designed to offer you value now and in the years to come. We are so confident in the quality of your home that we provide you with a two-year Workmanship Warranty – double the industry standard.</p>
<p>In cases where you do have to use our warranty service, our goal is to address your request in a timely and professional manner.</p>
<p>In order to best serve you, we ask that all requests for warranty service be submitted in writing to your customer service team. Requests can be submitted one of two ways:</p>
<p>-Please visit.</p>
<p>-By mail at .</p>
<p>Once we receive your warranty request, you can expect:</p>
<p>-A meeting with a member of our professional construction staff within 5 days to review your request.</p>
<p>-Resolution of your request in a professional and timely manner.</p>
<p>All warranty work will be scheduled at a time when you can be at home during business hours (Monday through Friday 8:00am to 5:00pm).</p>
<p>Homes not only built your home using quality products, we also installed quality mechanical systems and appliances in your new home. If you have a problem with an appliance or mechanical system, including air conditioning, electrical or plumbing, we ask that you first call the construction staff during normal business hours, as well as submit a request through our website.</p>
<p>Please be sure to register your appliances at www.geappliances.com and your AC unit at www.carrier.com. You will have 90 days from closing to register the AC unit.</p>
<p>Thank you again for choosing to purchase a new . We sincerely appreciate the trust you have placed in us, and we look forward to continuing to serve you.</p>
<p>Sincerely,</p>
</div>
</body>
</html>");
body = xhtml.ToString();
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress(emailFrom);
mail.To.Add(emailTo);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
// mail.Attachments.Add(new Attachment(@"C:\SomeFile.txt"));
// mail.Attachments.Add(new Attachment(@"C:\SomeZip.zip"));
using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
{
if (UseDefaultCredentials)
{
smtp.UseDefaultCredentials = true;
//smtp.Credentials = CredentialCache.DefaultNetworkCredentials;
}
else
{
smtp.Credentials = new NetworkCredential(emailFrom, password);
}
smtp.EnableSsl = enableSSL;
smtp.Send(mail);
}
}
Console.WriteLine("An e-mail has been successfully sent to: {0}.", emailTo);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}