Sending HTML email with CDO and adding variable in body.

Posted on 2004-11-30
Last Modified: 2007-12-19
I'm trying to send a HTML email with variables. This is what I have, and getting the following error:


//Request Data from PDF
var FirstName        = Request.form("FirstName")
var LastName         = Request.form("LastName")
var Email            = Request.form("Email")
var Ext              = Request.form("Ext")
var OfficeNumber     = Request.form("OfficeNumber")
var FlatPanel        = Request.form("FlatPanel")
var SmallMonitor     = Request.form("SmallMonitor")
var SevMonitor       = Request.form("SevMonitor")
var MonitorStand     = Request.form("MonitorStand")
var SmallPrinter     = Request.form("SmallPrinter")
var LargePrinter     = Request.form("LargePrinter")
var FlatbedScanner   = Request.form("FlatbedScanner")
var SelfUnits        = Request.form("SelfUnits")
var Bookcases        = Request.form("Bookcases")
var MiscEquipment    = Request.form("MiscEquipment")
var Comments         = Request.form("Comments")

// Email Information

var objMail = Server.CreateObject("CDO.Message");

      objMail.From = "";
      objMail.To = Email;
        objMail.Subject = "Earthquake Survey Confirmation";
      objMail.HTMLBody = "<P><body>Thanks <%= FirstName %>for your submission</body></p>";
      objMail = null;

//////Error I'm getting/////////

Technical Information (for support personnel)

Error Type:
Microsoft JScript compilation (0x800A03F7)
Unterminated string constant
/orderconfirm.asp, line 42, column 49

Question by:jkobz
    LVL 6

    Expert Comment

    Change the line to read this:

    objMail.HTMLBody = "<P><body>Thanks "& FirstName &"for your submission</body></p>";
    LVL 15

    Accepted Solution

    no if its javascript you have to do this

    objMail.HTMLBody = "<P><body>Thanks " + FirstName + "for your submission</body></p>";

    Author Comment

    Thanks pkaleda,

    Looks as if the stmp mail server is stripping away my html mail, so I guess I have to go the .textbody route. Is it possible to format text mail somehow? Or any other suggestions?

    LVL 33

    Assisted Solution

    try this?

    objMail.HTMLBody = "<body><p>Thanks " + FirstName + "for your submission</p></body>";
    LVL 33

    Expert Comment

    Also try this (before Send)

    objMail.MimeFormatted = true
    LVL 6

    Expert Comment

    also add(before Send):

    objMail.BodyFormat = 0
    objMail.MailFormat = 0

    Author Comment

    Thanks for the Feedback...

    Everything worked like a charm, except when I added...

    also add(before Send):

    objMail.BodyFormat = 0
    objMail.MailFormat = 0

    It stated object wasn't supported...

    LVL 33

    Expert Comment

    BodyFormat and MailFormat are properties of CDONTS (not CDO)

    >>Everything worked like a charm
    Yeah :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now