468,550 Members | 2,086 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,550 developers. It's quick & easy.

VB compilation error - Expected end of statement - help with syntax!

I know I am so close on this, but I cannot see what the syntax fix is. I am sending two e-mails via one asp page; one to the gift giver and one to the recipient...I originally had the message text in the YourMail.TextBody = equation, but kept getting syntax errors so have since moved my message body to another section. Nonetheless, I'm still having problems. I am calling mytxt from the virtual conn.asp file.

When I submit my form, I get the error:
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/cards/sent.asp, line 179

I'd greatly appreiciate help seeing what I'm not.... thanks!!

[code]
<%
RS.Close
Set RS = NOTHING
Conn.Close
Set Conn = NOTHING
mytxt2=mytxt2&postID

msgbody = ""
msgbody = msgbody & mytxt & vbcrlf&_
msgbody = msgbody & mytxt1 & VBCrLf & VBCrLf&_
msgbody = msgbody & mytxt2 & VBCrLf & VBCrLf&_
msgbody = msgbody & "The gift page will tell you more details about your gift." & VBCrLf & VBCrLf&_
msgbody = msgbody & "We invite you to get our monthly e-newsletter for more recipes. Click here to join:" & VBCrLf&_
msgbody = msgbody & "http://www.emailprodiver.com/signup.php" & VBCrLf & VBCrLf&_
msgbody = msgbody & "Cheers!" & VBCrLf&_
msgbody = msgbody & "Your friends at Business" & VBCrLf & VBCrLf & "www.mydomain.com" & VBCrLf & "Questions? E-mail us at subs@mydomain.com" & VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_

LINE 179 --> Dim YourMail
Set YourMail = Server.CreateObject("CDO.Message")
YourMail.From = f
YourMail.To = t
YourMail.Bcc = "me@mydomain.com"
YourMail.Subject = "Gift subscription from " &fn
YourMail.TextBody = msgbody


YourMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
YourMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
'Server port
YourMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
YourMail.Configuration.Fields.Update
YourMail.Send
set YourMail=nothing

msgbody = ""
msgbody = msgbody & "Thank you!" & VBCrLf&_
msgbody= msgbody & "Your e-card has been successfully sent to " &t & VBCrLf & VBCrLf&_
msgbody= msgbody & "You can view a copy of your e-card here:" & VBCrLf&_
msgbody= msgbody & mytxt2 & VBCrLf & VBCrLf&_
msgbody= msgbody & "Cheers!" & VBCrLf & VBCrLf&_
msgbody= msgbody & "Your friends at Business" & VBCrLf & VBCrLf & "www.mydomain.com" & VBCrLf & "Questions? E-mail us at subs@mydomain.com" & VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_

Dim TheirMail
Set TheirMail = Server.CreateObject("CDO.Message")
TheirMail.From = "Business <subs@mydomain.com>"
TheirMail.To = f
TheirMail.Bcc = "me@mydomain.com"
TheirMail.Subject = "E-Card Confirmation"
TheirMail.TextBody = msgbody


TheirMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
TheirMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
'Server port
TheirMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjMail.Configuration.Fields.Update
TheirMail.Send
set TheirMail=nothing


%>
[/CODE}
Dec 3 '07 #1
7 11996
JamieHowarth0
533 Expert 512MB
Hi siocodes,

Try commenting out the Dim line and tell us what happens.

Best regards,

medicineworker
Dec 4 '07 #2
Thanks, medicineworker. That does just causes a problem with the Server.CreateObject line.... I know there's something wrong with the syntax of the Text.Body of the message. I have all sorts of characters in there, but I do the same in another page (? and / and words like "if")

Here's the latest message code (I keep playing with it). Is there a way I don't know about to deliniate copy (vs. code) in the TextBody= statement?

Expand|Select|Wrap|Line Numbers
  1.     Dim ObjMail
  2.     Set ObjMail = Server.CreateObject("CDO.Message")
  3.     ObjMail.From = f
  4.     ObjMail.To = t
  5.     ObjMail.Subject = "XXXX gift subscription from " &fn
  6.     ObjMail.TextBody = "I have given you a subscription to XXXX" & vbcrlf&_
  7.     mytxt1 & VBCrLf & VBCrLf&_
  8.     mytxt2 & VBCrLf & VBCrLf&_
  9.     "We hope you enjoy your subscription to XXXX." & VBCrLf & VBCrLf&_
  10.     "Cheers!" & VBCrLf&_
  11.     "Your friends at XXX" & VBCrLf & VBCrLf & "www.mydomain.com" & VBCrLf & "Questions? E-mail us at me@mydomain.com" & VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_
  12.  
  13.   ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  14. 'Name or IP of remote SMTP server
  15.   ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
  16. 'Server port
  17.   ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
  18.   ObjMail.Configuration.Fields.Update
  19.     ObjMail.Send
  20.   set ObjMail=nothing
  21.  
Dec 4 '07 #3
Actually, now my problem is that I'm getting a Type Mismatch in the line "I have given you a s"

Thanks, medicineworker. That does just causes a problem with the Server.CreateObject line.... I know there's something wrong with the syntax of the Text.Body of the message. I have all sorts of characters in there, but I do the same in another page (? and / and words like "if")

Here's the latest message code (I keep playing with it). Is there a way I don't know about to deliniate copy (vs. code) in the TextBody= statement?

Expand|Select|Wrap|Line Numbers
  1.     Dim ObjMail
  2.     Set ObjMail = Server.CreateObject("CDO.Message")
  3.     ObjMail.From = f
  4.     ObjMail.To = t
  5.     ObjMail.Subject = "XXXX gift subscription from " &fn
  6.     ObjMail.TextBody = "I have given you a subscription to XXXX" & vbcrlf&_
  7.     mytxt1 & VBCrLf & VBCrLf&_
  8.     mytxt2 & VBCrLf & VBCrLf&_
  9.     "We hope you enjoy your subscription to XXXX." & VBCrLf & VBCrLf&_
  10.     "Cheers!" & VBCrLf&_
  11.     "Your friends at XXX" & VBCrLf & VBCrLf & "www.mydomain.com" & VBCrLf & "Questions? E-mail us at me@mydomain.com" & VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_
  12.  
  13.   ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  14. 'Name or IP of remote SMTP server
  15.   ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
  16. 'Server port
  17.   ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
  18.   ObjMail.Configuration.Fields.Update
  19.     ObjMail.Send
  20.   set ObjMail=nothing
  21.  
Dec 4 '07 #4
I figured it out myself. It was just line breaks in my msg body code string. I don't know why that would really matter, but it did.

And, fini!
Dec 5 '07 #5
JamieHowarth0
533 Expert 512MB
Hi siocodes,

Great job for getting it working yourself, thanks for telling us what your problem was too!

Did you get round it by using Chr(32) or by putting vbCrLf as opposed to vbcrlf (lower-case)?

medicineworker
Dec 5 '07 #6
Nicodemas
164 Expert 100+
negative... the problem was this:
Expand|Select|Wrap|Line Numbers
  1. VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_
  2.  
  3. LINE 179 --> Dim YourMail
  4.  
The "&_" was expecting create a concatenation, but you Dim'd a variable instead.

if you remove the "&_", it wouldn't render that error.
Dec 7 '07 #7
I also found the same problem, and it was in the body of the script. I used a formatting editor (Notepad++) to edit script and found a call that was not formatted correctly. Once I fixed that, it ran fine. Thanks Nicodemas for the help.
Oct 24 '11 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by deepdata | last post: by
9 posts views Thread by subramanian | last post: by
1 post views Thread by BSand0764 | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.