SMTPClient question

  • I have a package using the Send Email Task.

    On the SMTP connection, I have the smtp server specified and the Use Windows Authentication checked and the Enable Secure Sockets Layer unchecked.

    Now, I want to send an email that has some data from a table embedded in the body.

    So, I have added a Script Task with the following code:

    Dim myHtmlMessage As MailMessage

    Dim mySmtpClient As SmtpClient

    myHtmlMessage = New MailMessage("FromEmailaddress", "ToEmailAddress", "Test", Msg)

    mySmtpClient = New SmtpClient("smtp.server")

    mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials

    myHtmlMessage.IsBodyHtml = True

    Try

    mySmtpClient.Send(myHtmlMessage)

    Catch ex As Exception

    MsgBox(ex.Message.ToString)

    Dts.TaskResult = Dts.Results.Failure

    End Try

    The FromEmail and ToEmail are my own network email and the SMTPClient is my companies SMTP server, which is the same entry I had in the SMTP Connection Manager for the Send Email Task.

    When I run the code, I don't get any errors but I never receive the email.

    I'm trying to figure out why the Send Email Task works but this code does not.

    Any help would be great.

  • What type of mail server do you use for SMTP? If its Exchange and you use the mail relay functionaity you need to ensure that you allow the IP address of the server where the mail is being sent from is allow to connect and send via the mail relay admin GUI, there are two places you need to add the IP.

    Then also check that you dont have some sort of antivirus issue going on where it blocks mass mail worms, just to be on the safe side as I know from past experiences we had issues with McAfee stopping the mail services of SQL from sending and needed to be over-ridden by en ePO policy change.

  • The server is Exchange. Anti-virus is not an issue.

    As far as IP addresses go, wouldn't I have the same issue running the Send Email task (which works) on the same server??

  • Doh, yeah I missed that part when reading your post, my bad, sorry on that.

    Could you not make use of using DBMail instead if your passing over the results of a query via an execute SQL task instead of creating a script task to do it?

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

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