DTS Send Resultset in the body of an email as "text"

  • How can I change the objMail.TextBody = "test" in the following so it displays the SQL results of SELECT CategoryID FROM Categories in the body of an email as "text" ?

    ----------------------------------------------

    Function Main()

    Dim iMsg

    set iMsg = CreateObject("CDO.Message")

    Dim objMail

    Set objMail = CreateObject("CDO.Message")

    objMail.From = "test@test.com"

    objMail.To ="test@test.com"

    objMail.Subject="your subject here"

    objMail.TextBody = "test" <------------------ SQL statements here ?

    objMail.Send

    Set objMail = nothing

    Main = DTSTaskExecResult_Success

    End Function

  • store the output in a global variable which you can then access in your code


    ------------------------------
    The Users are always right - when I'm not wrong!

  • I found out how to get the output into a global variable, and tested some theories to make the below work, however I cannot seem to get it to work.

    Can you send me a sample or a hint ?

     

    Function Main()

    Dim iMsg

    set iMsg = CreateObject("CDO.Message")

    Dim objMail

    Set objMail = CreateObject("CDO.Message")

    objMail.From = "user@user.com"

    objMail.To ="user@user.com"

    objMail.Subject="Test Subject"

    objMail.TextBody = GlobalVariable (OIW_DOLLAR).Value <-- this fails

    objMail.Send

    Set objMail = nothing

    Main = DTSTaskExecResult_Success

    End Function

  • You are missing the quotes here:

    objMail.TextBody = GlobalVariable (OIW_DOLLAR).Value <-- this fails

     

    should be:

    objMail.TextBody = GlobalVariable ("OIW_DOLLAR").Value


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Thanks.

    Here is the final code if anyone needs it.

    objMail.TextBody = "Total is " & DTSGlobalVariables("OIW_DOLLAR").value

    Related Links:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dtssql/dts_addf_misc_68tv.asp

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/howtosql/ht_dts_task_6llt.asp

    http://www.google.com/search?q=Global+Variable+sql+activex&hl=en&lr=

     

     

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

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