Using the Script Task to Report Errors in SSIS

Learn how to configure your QuNect ODBC for QuickBase DSN

The two lines of code below go in the Imports section.



Imports System.Net
Imports System.Net.Mail

The following lines of code replace the comment "'Add your code here"

Dim Smtp_Client As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Client.UseDefaultCredentials = False
Dim SMTPUsername As String = Dts.Variables("User::SMTPUsername").Value.ToString()
Dim SMTPPassword As String = Dts.Variables("User::SMTPPassword").Value.ToString()
Smtp_Client.Credentials = New NetworkCredential(SMTPUsername, SMTPPassword)
Smtp_Client.Port = CInt(Dts.Variables("User::SMTPPort").Value)
Smtp_Client.EnableSsl = True
Smtp_Client.Host = Dts.Variables("User::SMTPServer").Value.ToString()

e_mail = New MailMessage()
e_mail.From = New MailAddress(Dts.Variables("User::From").Value.ToString())
e_mail.To.Add(Dts.Variables("User::To").Value.ToString())
e_mail.Subject = Dts.Variables("User::Subject").Value.ToString()
e_mail.IsBodyHtml = False
e_mail.Body = Dts.Variables("User::MessageBody").Value.ToString()
Smtp_Client.Send(e_mail)