Close smtp session script task

  • Greetings

    Is there any way to close an SMTP connection via a script task?

    The reason I need to do this is because SSIS packages are failing when doing two many send mail tasks in one session. Pausing the Task was effective for a while but the issue has more to do with SMTP server setting which I have no control over and I am getting some cooperation from net engineer but enough for me to move with a solution.

    Thanks!

  • I think you'll have to move away from the built-in task and do it from a script task. You can start with this code..

    Code to send mail for SSIS:

    Dim _oSMTPClient As New SmtpClient("smtpmailhost.yourcompany.com")

    Dim _oMailMsg As New MailMessage()

    _oMailMsg.From = New MailAddress("someemailaddress@yourcompany.com")

    _oMailMsg.To.Add("someotheremailaddress@yourcompany.com")

    _oMailMsg.Subject = "The Subject"

    _oMailMsg.Body = "Message Body"

    _oSMTPClient.Send(_oMailMsg)

    Don't forget:

    Imports System.Net.Mail

    CEWII

  • Real nice guitar man! But will that resolve the issue though if I am still using the same SMTP server and there are settings on the server that limit the number of emails sent per session?

  • It gives you all the control you want. You can open and close the connection the way you want.

    The code I gave is the starting point.. It is not finished product.

    CEWII

  • ok it seems like I have found the resolution to this problem and yes it is a setting in the SMTP server (in our case Exchange) not a problem with the SSIS package.

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

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