View Single Post
  #1 (permalink)  
Old April 14th, 2005, 11:03 AM
femig femig is offline
Registered User
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 = ""
strTo = oRs.Fields("useremail")
strReply_To = ""
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?

Reply With Quote