p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VBScript (http://p2p.wrox.com/forumdisplay.php?f=77)
-   -   error in my email vbs script (http://p2p.wrox.com/showthread.php?t=28142)

femig April 14th, 2005 11:03 AM

error in my email vbs script
i get an error when i run this..

'Option Explicit

Dim sServer
Dim sLogin
Dim sPwd
Dim oCn
Dim oRs
Dim sNames
Dim oFso
Dim oFileOut
Dim sLineOut
Dim strFrom
Dim strTo
Dim strReply_To
Dim strSubject
Dim strMessage

Dim Filename

Filename = "crystal_reports.pdf"

' Set the database connection information
sServer = "AGP1012284DT"
sLogin = "sa"
sPwd = "tavia"

' Create the ADO Connection and Recordset objects.
Set oCn = CreateObject( "ADODB.Connection" )
Set oRs = CreateObject( "ADODB.Recordset" )

' Create a FileSystemObject.
Set oFso = CreateObject("Scripting.FileSystemObject")

' Set the connection string, open the connection and get rows.
oCn.ConnectionString = "Driver={SQL Server}" & _
                       ";SERVER=" & sServer & _
                       ";UID=" & sLogin & _
                       ";PWD=" & sPwd & _
oRs.Open "Select useremail from Users ", oCn

'WScript.echo "test"

' Read through all the rows.

While Not oRs.EOF

strFrom = "femig@mtnnigeria.net"
strTo = oRs.Fields("useremail")
strReply_To = "femig@mtnnigeria.net"
strSubject = "VBS Script test + pdf attachment..Again"
strBody = "If you get this + the attachment, then we are on..Next is to get it to loop through a recordset and send emails..."

' Create the CDONTS NewMail object
Set myCDONTSMail = WScript.CreateObject("CDONTS.NewMail")

' Set the Reply-To header of the Newmail object:
myCDONTSMail.Value("Reply-To") = strReply_To

' Send the message and cleanup CDONTS objects

' Attach file
myCDONTSMail.AttachFile FileName

myCDONTSMail.Send strFrom, strTo, strSubject, strMessage

//WScript.echo "Email sent to " & oRs.Fields("useremail")

' We're finished—close the database objects.

the error is ..
Microsoft VBScript compilation error: Expected statement..
Can anyone show me where the error is?

mmcdonal April 15th, 2005 06:26 AM

What line is the error on? Your compilation error should tell you that. Do you have a script debugger?


All times are GMT -4. The time now is 05:26 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.