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.
Author |
Topic |
buhlig
Starting Member
1 Post |
Posted - 2002-09-27 : 21:25:32
|
Is anyone able to supply me with any information on this script? I keep getting an invalid connection string attribute in line 24 character 2 when I run the script...Im testing this for a client but cant seem to get this to work..All scripts are default within SQL2000 on the local server. I am attempting to run the VBscript from that machine by double clicking it.Im not very familiar with SQL scripting or vb scripting so this is almost greek to me, but I do understand the logic behind it.Thank you for any assistance..BenHere is a copy of the vbs script, with accounts and names ****** out'---------------------------------------'SendMail.vbs'Author: Damian Maclennan - merkin@sqlteam.com'Disclaimer : This code is provided "as is" and has no warranites either implied or 'explicit. '--------------------'ADO ConstantsConst adCmdStoredProc = &H0004'--------------------'System configConst ConnString = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=sqlmail; UserID=*********; Password=********"Const MailServer = "mail.*********.net"Call MainSub Main() dim sFromName, sFromAddress, sToName, sToAddress, sSubject, sBody dim objCmd, objRs 'ADO Command Object Set objCmd = CreateObject("ADODB.Command") objCmd.ActiveConnection = ConnString objCmd.CommandType = adCmdStoredProc objCmd.CommandText = "GetMailQueue" 'Our Stored procedure Set objRS = objCmd.execute 'Gets an ADO recordset of all the emails do until objRs.EOF 'Loop through the emails sFromName = objRs("FromName") sFromAddress = objRs("FromAddress") sToName = objRs("ToName") sToAddress = objRs("ToAddress") sSubject = objRs("Subject") sBody = objRs("Body") 'Call our mail subroutine Call SendMail(sFromName, sFromAddress, sToName, sToAddress, sSubject, sBody) objRS.movenext loop 'Clean up objRS.close Set objRS = nothing Set objCmd = nothing End SubSub SendMail(sFromName, sFromAddress, sToName, sToAddress, sSubject, sBody) dim objMail, errCode 'Create the mail object Set objMail = CreateObject("SMTPsvg.Mailer") 'Set all the properties for this email objMail.RemoteHost = MailServer objMail.FromName = sFromName objMail.FromAddress = sFromAddress objMail.AddRecipient sToName, sToAddress objMail.Subject = sSubject objMail.BodyText = sBody 'Send it errCode = objMail.SendMail 'Clean up Set objMail = nothingEnd SubEdited by - buhlig on 09/27/2002 21:26:16Edited by - buhlig on 09/27/2002 21:27:04 |
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-09-28 : 05:02:42
|
HiTry putting a space in "UserID" so it's like "User ID"Damian |
 |
|
|
|
|
|
|