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
 Import/Export (DTS) and Replication (2000)
 VB Script in DTS package

Author  Topic 

julesr
Starting Member

14 Posts

Posted - 2003-11-14 : 05:57:43
I've created a DTS package. It contains a series of ActiveX Script Tasks. All the VB script executes OK apart from the script below. I just can't figure out what's the problem is. The error message is "ActiveX scripting encountered a runtime error during the execution of the script". The same script runs fine from an ASP page. I'd appreciate any pointers. Thanks.

------------------------------------
Function Main()
Call SendCDOMail()
Main = DTSTaskExecResult_Success
End Function

Function SendCDOMail()
'On Error Resume Next

Dim iMsg, Flds, iConf

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"

Flds.Update

Set iMsg.Configuration = iConf
iMsg.To = "jules@charon.co.uk"
iMsg.From = "jules@charon.co.uk"
iMsg.Subject = "subj"
iMsg.TextBody = "some text"
iMsg.Send

End Function
---------------------------------------------

Jules
http://www.charon.co.uk

julesr
Starting Member

14 Posts

Posted - 2003-11-14 : 06:18:54
Well, this is typical. I spend hours last night to try and solve this to no avail. Then, after posting, I solve it a minutes later. The solution is to use this. Not sure why the Configuration object is being baulked at.

Function Main()
Call SendCDOMail()
Main = DTSTaskExecResult_Success
End Function

Function SendCDOMail()
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
iMsg.To = "jules@charon.co.uk"
iMsg.From = "jules@charon.co.uk"
iMsg.Subject = "subj"
iMsg.TextBody = "some text"
iMsg.Send
Set iMsg = Nothing
End Function

Jules
http://www.charon.co.uk
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-11-14 : 06:48:52
quote:
Then, after posting, I solve it a minutes later.

Yes!! It's just an incredible Law of (Human) Nature.

BTW the same case with posted answers :)
Go to Top of Page
   

- Advertisement -