sending email from script task

  • Have you verified that the smtp server is accepting mail from your server? It might be as simple as checking the smtp server configuration and values in your variables.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I checked all the variables value and it comes correct and without variable it works fine.

    Not sure what is causing this

  • I had a problem with this a while back.

    Only thing I can suggest trying is seeing if your email server allow relaying or not. SSIS seemed to tell fibs occasionally saying an email send was successful when it strictly wasn't true. Alternatively, the email could have been created and sent but blocked internally as somewhere down the line it was considered as spam.

  • This works for me:

    Imports System

    Imports Microsoft.SqlServer.Dts.Runtime

    Imports System.Net.Mail

    Imports System.Net

    Public Sub Main()

    Dim myHtmlMessage As New MailMessage()

    Dim mySmtpClient As SmtpClient

    Dim theMessage As String

    theMessage = "Hello, it is now " & Now().ToString & "."

    myHtmlMessage.From = New MailAddress("fl@yourschool.edu", "First Last")

    myHtmlMessage.To.Add(New MailAddress("fl@yourschool.edu", "First Last"))

    myHtmlMessage.Subject = "Tell you the time..."

    myHtmlMessage.Body = theMessage

    mySmtpClient = New SmtpClient("mail.yourschool.edu")

    mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials

    Try

    mySmtpClient.Send(myHtmlMessage)

    Catch ex As Exception

    MsgBox(ex.Message.ToString)

    End Try

    Dts.TaskResult = ScriptResults.Success

    End Sub

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply