here you are:
Option Explicit
Function Main()
Dim oPkg, oTasks, oSendMailTask
' Get Package object
Set oPkg = DTSGlobalVariables.Parent
' Get Tasks collection
Set oTasks = oPkg.Tasks
' Get DTS Send Mail Task by Name
Set oSendMailTask = oTasks("DTSTask_DTSSendMailTask_1").CustomTask
' Set Subject to the Package Name
oSendMailTask.Subject = oPkg.Name
' Set Message Text, including a global variable value
oSendMailTask.MessageText = "Dummy Text." & vbCrLf & _
"MyGlobalVariable Value :" & DTSGlobalVariables("MyGlobalVariable").Value
' Set the attachement to the file of the named connection
oSendMailTask.FileAttachments = oPkg.Connections("Text File
(Destination)").DataSource
' Clean Up
Set oSendMailTask = Nothing
Set oTasks = Nothing
Set oPkg = Nothing
Main = DTSTaskExecResult_Success
End Function
but i would advise you not to use the dts mail task, as it needs a MAPI
client installed on the server. use instead a command line utility like blat
(http://www.blat.net/), which is a lot more easy to configure and more
stable to use.
Regards
Leo Matter
"Simon M" <SimonM (AT) discussions (DOT) microsoft.com> wrote
Quote:
Is there a way to include the error message returned when a step in a DTS
package fails, and then include this in an email task?
Thanks |