SSIS: Send SMTP mail from Script task

Here i will show how to send SMTP email from a script task rather than the SMTP Mail Task.

Imports System
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net.Mail
Imports System.Net

Public Class ScriptMain
Public Sub Main()
Dim myHtmlMessage As MailMessage
Dim mySmtpClient As SmtpClient

myHtmlMessage=New MailMessage(name@helpindotnet.blogspot.com,
“name@helpindotnet.blogspot.com”, “Subject”, “body”)
mySmtpClient = New SmtpClient(“192.168.3.75″)
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(myHtmlMessage)
Dts.TaskResult = Dts.Results.Success

Dts.TaskResult = Dts.Results.Success
End Sub
End Class

2 Responses

  1. your site is very nice …
    this is very helpful and attractive.

  2. sasasas

Leave a Reply