title: SSIS - DTS Script Task has encountered an exception in user code
body: <p>I've had about 10 packages that have been running pretty much flawlessly for months.  These packages utilize the same script task that I've basically copied across all the packages.  All this script task does is send an email.  I came in to work on Monday and all of a sudden I'm getting this DTS Script Task error on all the packages as soon as it hits the email script task.  Literally nothing has changed with any of these packages and I'm unsure of what steps to take to fix it.</p>
  
  <pre><code>#Region "Imports"
  Imports System
  Imports System.Data
  Imports System.Math
  Imports Microsoft.SqlServer.Dts.Runtime
  #End Region
  
  Public Sub Main()
  
      'send email notification
      Dim message As String = "message goes here"
      sendEmail("email@email.com", "Subject is here", message)
  
  
  
      Dts.TaskResult = ScriptResults.Success
  End Sub
  
  
  Sub sendEmail(ByRef toaddr As String, ByRef sbj As String, ByRef msg As String)
      Dim objOutlook As Object
      Dim objOutlookMsg As Object
      objOutlook = CreateObject("Outlook.Application")
      objOutlookMsg = objOutlook.CreateItem(0)
      With objOutlookMsg
          .To = toaddr
          .Subject = sbj
          .Body = msg
          .sentonbehalfofname = "email@email.com"
          .Send()
      End With
      objOutlookMsg = Nothing
      objOutlook = Nothing
  End Sub
  </code></pre>
  
  <p>When I step through the code, it seems to happen here:</p>
  
  <p><a href="https://i.stack.imgur.com/PAVG1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PAVG1.jpg" alt="enter image description here"></a></p>
  
  <p>Any help you can provide would be greatly appreciated.</p>