DTS - sending Email

DaBoo_
01-14-2004, 06:55 AM
Hi!

I have program my first DTS Package for the Microsoft SQL Server 7.0.

With the fallowing rows i am going to send an email over CDONTS.


Sub SendMail(sFromAddress, sToAddress, sSubject, sBody)
Dim objMail, errCode

'Create the mail object
Set objMail = CreateObject("CDONTS.NewMail")

'Set all the properties for this email
objMail.From = sFromAddress
objMail.To = sToAddress
objMail.Subject = sSubject
objMail.Body = sBody
objMail.Send

'Clean up
Set objMail = nothing
End Sub


But if the DTS runs, the fallowing error occurs:

Error Code: 0
ErrorSource=Microsoft VBScript runtime error
Error Description: ActiveX component can't create object

Error on Line 77


The Code in Line 77 is "objMail.Send". If i take it out, the DTS runs without any problem! I tried to code the mail properties hard ("objMail.From = "xxx@xxx.com") but it do not works too.

Somebody could help me??!

Thanks a lot! Greetings, DaBoo_

nelly25
01-14-2004, 10:04 AM
Try putting a Server. infront of CreateObject("CDONTS.NewMail")

vbQuestor
01-14-2004, 09:26 PM
I think you mean behide don't you? eg

set objMail = CreateObject("CDONTS.NewMail", ServerName)

DaBoo_
01-15-2004, 02:46 AM
Try putting a Server. infront of CreateObject("CDONTS.NewMail")

Hi!

Thx for your answer! But..."Server"...what do you mean? I think, it's not a String? An object? Which type is it? For example, if the server called "John".

@vbQuestor:
Thank you! But the Same problem...! A String don't works!

I got the feeling that I am as thick as two short planks.

Greetz, DaBoo

vbQuestor
01-15-2004, 07:44 PM
Where is the object CDONTS located. Is it on the same machine your running your code from, or another machine? Is CDONTS a dll or ActiveX server?

If CDONTS is a dll on a different machine, you'll have to register it on the machine your running your code on. Whether CDONTS is on the same machine or a different one, you'll have to set a reference to it in your app. Not knowing what CDONTS is kind of hampers me here though.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum