Thursday, July 13, 2006

Sql25k.SSIS: SMTP mail from the Script Task

A lot of people need obviously to send email. That's fine. But we might know that SMTP Mail task doesn't support sending email when you use http protocol.However, it's possible to use the script task in order to achieve this.

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


Public Class ScriptMain

Public Sub Send_Email()


Dim Message As MailMessage
Dim Client-SMTP As SmtpClient

Message=New MailMessage(evivesg@cam.es,"evivesg@cam.es", "test1", "xxxxxxxxxxx")

--to allocate IP ADRESS Client-SMTP = New SmtpClient("nnn.nnn.n.nn")

Client-SMTP.Credentials = CredentialCache.DefaultNetworkCredentials
Client-SMTP.Send(Message)

Dts.TaskResult = Dts.Results.Success
End Sub

End Class

0 Comments:

Post a Comment

<< Home