Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 14th, 2005, 11:03 AM
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 = "[email protected]"
strTo = oRs.Fields("useremail")
strReply_To = "[email protected]"
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
  #2 (permalink)  
Old April 15th, 2005, 06:26 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

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

Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I attach a file to an email in my .vbs file savoym VBScript 3 July 2nd, 2011 08:02 AM
error in .vbs FTP routine invoked from VB 6.0 dgr7 VBScript 0 February 7th, 2007 05:29 PM
error in script i downloaded knightneo BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 January 3rd, 2007 12:41 AM
Simple VBS Email daslick VB How-To 0 November 20th, 2005 07:41 PM
how to create an email id through php script manu_mcs Pro PHP 0 December 8th, 2003 03:33 PM

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