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)
 VBScript and Jobs!

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-11-05 : 00:18:15
Mike writes "Hello, I'm creating a system similar to the Mail Queue System you had an article about for not so long ago. I'm trying to use this code below in a job that executes every minute, just for now though, when it's dont is suppose to be once a week. But anyway, everyting works fine, BUT only when that comment in then SendMail sub is present, otherwise it complains about objects not being destroyed. GAH! What am I doing wrong ?

Thanks for any kind of help.

System: Win 2000, SQL Server 2000

Sub Main()
dim sFromName, sFromAddress, sToName, sToAddress, sSubject, sBody
dim objCmd, objRs

Set objCmd = CreateObject("ADODB.Command")
objCmd.ActiveConnection = "DSN=genointra;UID=geno;PWD=123456"
objCmd.CommandText = "SELECT * FROM objects"
Set objRS = objCmd.execute

do until objRS.eof
sBody = sBody & objRS("title")
objRS.movenext
loop

Call SendMail("info@arentuna.nu", "sleepy@linc-up.com", "Test", sBody)

objRS.close
Set objRS = nothing
Set objCmd = nothing
End Sub

Sub SendMail(sFromAddress, sToAddress, sSubject, sBody)
dim objMail

Set objMail = CreateObject("CDONTS.NewMail")

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

Set objMail = nothing
End Sub"
   

- Advertisement -