/Home/H2O Sample Code/Form with Template Email

    The code below can be used to send HTML emails using information posted on an HTML form. The code is template-driven, meaning, the format of the email is stored in a seperate file (as a two-coumn CSV file containing both the subject line and the body text) so changes to the email can be made without changing code.

    The H2O Code Explained
    When the HTML form is submitted, the overlay processform is run. The top of the overlay loads the 2-column template, putting the first cell in the variable mytext and the second into mysubject. Then search and replace's are done on the text in the template using the variables submited in the HTML form.

    Then the function NETMAILSEND is used to send the email composed and the user is directed to a thank-you web page.

    email.html
    <html>
    <title>Form with Template Email</title>
    <form method=post action=processform>
    First Name: <input type=text name=firstname size=15><br>
    Last Name: <input type=text name=lastname size=20><br>
    Street Address: <input type=text name=streetaddress size=40><br>
    City: <input type=text name=city size=20><br>
    State, Zip: <input type=text name=state size=2 maxsize=2><br>  
    <input type=text name=zipcode size=10><br>
    Email: <input type=text name=email size=40><br>
    Phone: <input type=text name=phone size=40><br>
    Comments:<br>
    <textarea name=comments rows=5 cols=40>
    </textarea><br>
    <input type=submit value="Send">
    </form>
    </html>
    
    <<OVERLAY processform
        email_templatename="template.txt"
        COPY FILE=email_templatename TS="," TO void /COPY
        mytext=void[1]
        mysubject=void[2]
        # perform search and replace on text /#
        mytext=REPLACEALL(mytext,"[FirstName]",firstname)
        mytext=REPLACEALL(mytext,"[LastName]",lastname)
        mytext=REPLACEALL(mytext,"[Street]",streetaddres)
        mytext=REPLACEALL(mytext,"[City]",city)
        mytext=REPLACEALL(mytext,"[State]",state)
        mytext=REPLACEALL(mytext,"[Zip]",zip)
        mytext=REPLACEALL(mytext,"[email]",email)
        mytext=REPLACEALL(mytext,"[phone]",phone)
        mytext=REPLACEALL(mytext,"[comments]",comments)
        # perform search and replace on subject /#
        mysubject=REPLACEALL(mysubject,"[FirstName]",firstname)
        mysubject=REPLACEALL(mysubject,"[LastName]",lastname)
    
        NETMAILSEND("","yourname@yourserver.com",mysubject,mytext,
                    "40","","text/html","")
        GOTO "thank_you.html"
      >>
    
    
    NOTE: This code assumes you are sending HTML email. If not, replace the line:
        NETMAILSEND("","yourname@yourserver.com",mysubject,mytext,"40","","text/html","")
    with:
        MAIL mytext TO Address="yourname@yourserver.com" SUBJECT=mysubject /MAIL
    
    
    



SUPPORTING THE WEB'S BROWSER   
AND HARDWARE PLATFORMS   

COPYRIGHT 2004, AESTIVA, LLC. ALL RIGHTS RESERVED.