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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siocodes
    New Member
    • Dec 2007
    • 5

    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.TextBo dy = 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&p ostID

    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.emailprodiv er.com/signup.php" & VBCrLf & VBCrLf&_
    msgbody = msgbody & "Cheers!" & VBCrLf&_
    msgbody = msgbody & "Your friends at Business" & VBCrLf & VBCrLf & "www.mydomain.c om" & VBCrLf & "Questions? E-mail us at subs@mydomain.c om" & VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_

    LINE 179 --> Dim YourMail
    Set YourMail = Server.CreateOb ject("CDO.Messa ge")
    YourMail.From = f
    YourMail.To = t
    YourMail.Bcc = "me@mydomain.co m"
    YourMail.Subjec t = "Gift subscription from " &fn
    YourMail.TextBo dy = msgbody


    YourMail.Config uration.Fields. Item ("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2
    'Name or IP of remote SMTP server
    YourMail.Config uration.Fields. Item ("http://schemas.microso ft.com/cdo/configuration/smtpserver") = "localhost"
    'Server port
    YourMail.Config uration.Fields. Item ("http://schemas.microso ft.com/cdo/configuration/smtpserverport" ) = 25
    YourMail.Config uration.Fields. Update
    YourMail.Send
    set YourMail=nothin g

    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.c om" & VBCrLf & "Questions? E-mail us at subs@mydomain.c om" & VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_

    Dim TheirMail
    Set TheirMail = Server.CreateOb ject("CDO.Messa ge")
    TheirMail.From = "Business <subs@mydomain. com>"
    TheirMail.To = f
    TheirMail.Bcc = "me@mydomain.co m"
    TheirMail.Subje ct = "E-Card Confirmation"
    TheirMail.TextB ody = msgbody


    TheirMail.Confi guration.Fields .Item ("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2
    'Name or IP of remote SMTP server
    TheirMail.Confi guration.Fields .Item ("http://schemas.microso ft.com/cdo/configuration/smtpserver") = "localhost"
    'Server port
    TheirMail.Confi guration.Fields .Item ("http://schemas.microso ft.com/cdo/configuration/smtpserverport" ) = 25
    ObjMail.Configu ration.Fields.U pdate
    TheirMail.Send
    set TheirMail=nothi ng


    %>
    [/CODE}
  • JamieHowarth0
    Recognized Expert Contributor
    • May 2007
    • 537

    #2
    Hi siocodes,

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

    Best regards,

    medicineworker

    Comment

    • siocodes
      New Member
      • Dec 2007
      • 5

      #3
      Thanks, medicineworker. That does just causes a problem with the Server.CreateOb ject 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?

      Code:
      	Dim ObjMail
      	Set ObjMail = Server.CreateObject("CDO.Message")
      	ObjMail.From = f
      	ObjMail.To = t
      	ObjMail.Subject = "XXXX gift subscription from " &fn
      	ObjMail.TextBody = "I have given you a subscription to XXXX" & vbcrlf&_
      	mytxt1 & VBCrLf & VBCrLf&_
      	mytxt2 & VBCrLf & VBCrLf&_
      	"We hope you enjoy your subscription to XXXX." & VBCrLf & VBCrLf&_
      	"Cheers!" & VBCrLf&_
      	"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&_
      
        ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      'Name or IP of remote SMTP server
        ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
      'Server port
        ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
        ObjMail.Configuration.Fields.Update
      	ObjMail.Send
        set ObjMail=nothing

      Comment

      • siocodes
        New Member
        • Dec 2007
        • 5

        #4
        Actually, now my problem is that I'm getting a Type Mismatch in the line "I have given you a s"

        Originally posted by siocodes
        Thanks, medicineworker. That does just causes a problem with the Server.CreateOb ject 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?

        Code:
        	Dim ObjMail
        	Set ObjMail = Server.CreateObject("CDO.Message")
        	ObjMail.From = f
        	ObjMail.To = t
        	ObjMail.Subject = "XXXX gift subscription from " &fn
        	ObjMail.TextBody = "I have given you a subscription to XXXX" & vbcrlf&_
        	mytxt1 & VBCrLf & VBCrLf&_
        	mytxt2 & VBCrLf & VBCrLf&_
        	"We hope you enjoy your subscription to XXXX." & VBCrLf & VBCrLf&_
        	"Cheers!" & VBCrLf&_
        	"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&_
        
          ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        'Name or IP of remote SMTP server
          ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
        'Server port
          ObjMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
          ObjMail.Configuration.Fields.Update
        	ObjMail.Send
          set ObjMail=nothing

        Comment

        • siocodes
          New Member
          • Dec 2007
          • 5

          #5
          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!

          Comment

          • JamieHowarth0
            Recognized Expert Contributor
            • May 2007
            • 537

            #6
            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

            Comment

            • Nicodemas
              Recognized Expert New Member
              • Nov 2007
              • 164

              #7
              negative... the problem was this:
              Code:
              VBCrLf & "or toll-free: 1-877-555-1212" & VBCrLf&_
              
              LINE 179 --> Dim YourMail
              The "&_" was expecting create a concatenation, but you Dim'd a variable instead.

              if you remove the "&_", it wouldn't render that error.

              Comment

              • manusamoa
                New Member
                • Oct 2011
                • 1

                #8
                Thanks for the help

                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.

                Comment

                Working...