0

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.

#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 protected]", "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 protected]"
        .Send()
    End With
    objOutlookMsg = Nothing
    objOutlook = Nothing
End Sub

When I step through the code, it seems to happen here:

enter image description here

Any help you can provide would be greatly appreciated.

1 Answer 1

1

Wherever you are running your package (locally? on a server?) the Outlook object no longer exists (or there is a permission issue - but this is unlikely)

Dependencies like this are always difficult to manage when systems change - and they always will! It's difficult to be 100% sure because I can't see from your example what you are sending in your email - but I would recommend you ditch the script altogether and use the Send Mail Task task.

Sign up to request clarification or add additional context in comments.

4 Comments

+1. I used to have nightmares about "Cannot create ActiveX component". CreateObject is not a reliable way to do things. With email, there's the Send Mail task and making a direct SMTP connection in code as much better alternatives.
I can't use the send mail task because of my company's email setup...can't remember why exactly, but I did a bunch of research because I couldn't get that to work and ended up settling on the script task..
I'm currently running the packages locally
I suggest you write a VB Script which attempts to simulate the script - once you have that working you can paste it into your package. I do strongly recommend you follow the answer posted instead though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.