CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • Microsoft VBScript compilation error '800a0412' Must be first statement on the line

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    154
  • Date Created
    Wednesday, December 21, 2011
  • Last Updated
    Wednesday, December 21, 2011
  • This Article Has been Viewed
    3088 times
  • Short Desc
    When you are creating your script for CDOSYS Email, you may run into this error, when you are adding in if statements into your code, to show or not show a specific thing to a client message.
  • Details
    When you are creating your script for HTMLBody Email for CDOSYS emails, you may run into a situation, where you will need to send data that is generated from your database.
    When using IF and ELSEIF Statements in your CDOSYS code, for the HTMLBody message, it can get a little touchy, and does take some expertise in order to write the code out properly.
    And then, there are sometimes, that not matter how much experience one may have, error and issues will arise themselves.

    In that case, you have to separate your
    <%
    myMail.HTMLBody = myMail.HTMLBody & "Information goes here" & vbCrLf _
    %>


    Working with your database with generated emails, makes your work a lot easier, and more simplified, than sending out individual emails to your clientele.

    The below error happens when you forget to close a line above an ELSE or ELSEIF statement.

     

    Microsoft VBScript compilation error '800a0412'
    Must be first statement on the line
    /NewPost.asp, line 95

    else
    ^
  • Recreate Issue
    To recreate this issue.

    <%
    if rsNew.eof then
    myMail.HTMLBody=myMail.HTMLBody & "Information goes here" & vbCrLf _
    else
    myMail.HTMLBody=myMail.HTMLBody & "another line of information goes here" & vbCrLf
    end if
    %>


    Looking at the above code example, on the 2nd line of code, the & vbCrLf _ is making the 3rd line, which is our ELSE, into a 3rd line, instead of a first line.
  • Resolve Issue
    To resolve this issue.

    <%
    if rsNew.eof then
    myMail.HTMLBody=myMail.HTMLBody & "Information goes here" & vbCrLf
    else
    myMail.HTMLBody=myMail.HTMLBody & "another line of information goes here" & vbCrLf
    end if
    %>


    As you can see in the above corrected example, we have removed the _ (underscore) from the ending of the vbCrLf, so that it is now the end of the line, and the ELSE if the beginning of the line.