Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problem sending mail in DTS package

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-06 : 08:04:22
Jill writes "I have the following ActiveX Script in a DTS package. This script is the only thing that is in the package. Basically, I do an update on a table every night in another package. In this script, I want to check and see if there are any new codes added to a certain table after the update by the other package. If there are, I want the script to send me an e-mail letting me know.

Below is the popup error I get:
Error Source: Microsoft OLE DB Provider for SQL Server
Error Description: Invalid Task Result value. Mail sent.

Below is my ActiveX Script in my DTS package.
Function Main()
Dim adoConn, adoRst, adoCmd
Dim intCount, strCodes

intCount = 0
strCodes = ""

Set adoConn = CreateObject("ADODB.Connection")
Set adoRst = CreateObject("ADODB.Recordset")
Set adoCmd = CreateObject("ADODB.Command")

adoConn.ConnectionString = myConnectionString 'where i put my actual connection string
adoConn.Open

adoCmd.ActiveConnection = adoConn
adoCmd.CommandText = "SELECT DISTINCT myField FROM myTable WHERE myField NOT IN('C', 'CP', 'G', 'G2', 'G3', 'LL', 'M', 'M2', 'U', 'X') AND RTRIM(myField) <> '' "

Set adoRst = adoCmd.Execute
If not adoRst.EOF then
do while not adoRst.EOF
intCount = intCount + 1
if strCodes = "" then
strCodes = strCodes & adoRst(0)
else
strCodes = strCodes & ", " & adoRst(0)
end if
adoRst.Movenext
loop
End If
Set adRst = nothing

if intCount > 0 then
strSQL = "EXEC master.dbo.xp_sendmail @recipients = 'myemail@mydomain.com', @message = '" & strCodes & "', @subject = 'New Division Codes Found' "
adoCmd.CommandText = strSQL
adoCmd.Execute
End If

Set adoCmd = nothing
Set adoConn = nothing

End Function


I get the error when I right click on the ActiveXScript and Execute Step. I do get the e-mail, however.

Any ideas on what I'm doing to cause the error? I'm on Win2K SP3, SQL 2000 SP3.

Thanks,
Jill"
   

- Advertisement -