Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > VBScript
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 14th, 2005, 11:03 AM
Registered User
Join Date: Jan 2005
Location: , , .
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 = "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?

Reply With Quote
  #2 (permalink)  
Old April 15th, 2005, 06:26 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 07:40 AM.

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