Tuesday, March 20, 2012

Calling DTS package with Send Mail object from VB

I have several processes that call DTS packages (SQL Sever 7) from VB6, and they work fine. The problem is that if there is a "Send mail" task in the package, it won't send the email if called from VB.

If I run the package directly through enterprise manager, the email gets sent, but if run through VB it does not.

Any ideas?

The vb code is below.

Thanks.

Lionel

Private Sub Command1_Click()

Dim objPackage As DTS.Package
Const DTSReposFlag_UseTrustedConnection = 256
Dim tServer As String

Set objPackage = New DTS.Package
tServer = "SQLBOX"
objPackage.LoadFromSQLServer tServer, "", "", DTSReposFlag_UseTrustedConnection, "", "", "", "dts_test"
objPackage.Execute
Set objPackage = Nothing

End SubPlease, post your DTS task that includes a call to xp_sendmail.|||I'm not actually sure how to post the DTS Package. When I script it through enterprise manager (Open the package and Save AS) then it saves in a unreadable format

(e.g. DZ b% o?`;\ D|Jkjìg).

Please could you let me know.

Thanks,

lwakersql

No comments:

Post a Comment