# Sending HTML formated email with CDOSYS

**URL:** <https://forum.kirupa.com/t/sending-html-formated-email-with-cdosys/304701>\
**Category:** programming\
**Created:** [February 12, 2010, 4:29am UTC](https://forum.kirupa.com/t/sending-html-formated-email-with-cdosys/304701 "2010-02-12T04:29:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmartinez916](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jmartinez916](https://forum.kirupa.com/u/jmartinez916)\
**Post date:** [February 12, 2010, 4:29am UTC](https://forum.kirupa.com/t/sending-html-formated-email-with-cdosys/304701/1 "2010-02-12T04:29:49Z")

</div>

I’m having trouble sending my emails in an html format using CDOSYS, it sends fine in text…my code is below

```auto

<%
    
  Option Explicit

  dim sFname, sEmail, sMessage, sAddress, sPhone, sLoan, sLname
    dim oCdoMail, oCdoConf, sConfURL

 
    sFname = Request.Form("fname")
    sLname = Request.Form("lname")
    sEmail = Request.Form("email")
    sPhone = Request.Form("phone")
    sAddress = Request.Form("address")
    sLoan = Request.Form("loan")
    sMessage = Request.Form("comments")

        Set oCdoMail = Server.CreateObject("CDO.Message")
        Set oCdoConf = Server.CreateObject("CDO.Configuration")

        sConfURL = "http://schemas.microsoft.com/cdo/configuration/"

        with oCdoConf
            .Fields.Item(sConfURL & "sendusing") = 2
            .Fields.Item(sConfURL & "smtpserver") = "relay-hosting.secureserver.net"
            .Fields.Item(sConfURL & "smtpserverport") = 25
            .Fields.Update
        end with

        with oCdoMail
            .To = "test@home.com"
            .From = "test@home.com"
            .Subject = "Contact From "
            '.TextBody = sMessage
            .HTMLBody = "<html><body>Name: '"& sFname"' &nbsp '"& sLname"' Email '"& sEmail"' Phone: '"& sPhone"' Address: '"& sAddress"' Loan Amount: '"& sLoan"' Message: '"& sMessage"' </body></html> "
            .Configuration = oCdoConf
            .Send
        end with

        Set oCdoConf = Nothing
        Set oCdoMail = Nothing

    

%>

```

I’m trying to separate the different form elements ( First Name, Last Name etc…) when I send them in plain text it comes out as one long line, but when I send it as html I get a 500 - Internal server error.

I’m new to coding so any help would be appreciated

Thank you
