Showing posts with label mail. Show all posts
Showing posts with label mail. Show all posts

Sunday, January 18, 2009

using SSIS for send out mail

Here's my code that uses both port and BCC:

fromAddress = New MailAddress("foo@bar.co.uk", "Database Mail")
toAddress = New MailAddress("somebody@somewhere.co.uk", "Data Group")
bccAddress = New MailAddress("somebody.else@somewhere.co.uk", "Data Group")

message = New MailMessage(fromAddress, toAddress)
messag.Bcc.Add(bccAddress)
message.Subject = "Data Mart Load Start"
message.Priority = MailPriority.High
message.IsBodyHtml = False
message.Body = "The Data Mart load process has started. Please exit all reporting systems until notified that the load process has completed."

smtpClient = New SmtpClient("mail.bar.co.uk", 2525)
smtpClient.Credentials = New System.Net.NetworkCredential("login", "password")
smtpClient.Send(message)
Dts.TaskResult = Dts.Results.Success