Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    Interlacing HTML in CDONTS

    Hello

    I have the following CDONTS script:

    Dim ObjMail
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    ObjMail.BodyFormat = 0
    ObjMail.MailFormat = 0
    ObjMail.To = "myEmail@whatever.com"
    ObjMail.CC = sEmailAddress
    ObjMail.From = sEmailAddress
    ObjMail.Subject = "Feedback"
    ObjMail.Body = sFullNameTitle & vbcrlf&_
    sFullName & vbcrlf&_
    sEmailTitle & vbcrlf&_
    sEmailAddress & vbcrlf&_
    sBusinessTitle & vbcrlf&_
    sBusinessName & vbcrlf&_
    sCountryTitle & vbcrlf&_
    sCountryName & vbcrlf&_
    MessageName & vbcrlf&_
    MessageTitle
    ObjMail.Send
    Set ObjMail = Nothing
    %>

    The visitor to the site fills in an online form and the script above sends a copy of the information input to the Webmaster and the site visitor himself.

    This is the format it is received in:

    Fullname harry totti Email tomas@hotmail.com Business Nowt Country Nowhere Message me

    How can I create a far more attractive message, such as:

    Fullname
    His name
    Email

    etc to appear as in a short list? Where would I insert the HTML in the above CDONTS code?

    Many thanks for any advice.

    Steve

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    ObjMail.Body => ObjMail.HTMLBody

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello BarrMan

    Thank you for your message.

    So I insert ObjMail.Body => ObjMail.HTMLBody as follows?

    Dim ObjMail
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    ObjMail.BodyFormat = 0
    ObjMail.MailFormat = 0
    ObjMail.To = "myEmail@whatever.com"
    ObjMail.CC = sEmailAddress
    ObjMail.From = sEmailAddress
    ObjMail.Subject = "Feedback"
    ObjMail.HTMLBody
    ObjMail.Body = sFullNameTitle & vbcrlf&_
    sFullName & vbcrlf&_
    sEmailTitle & vbcrlf&_
    sEmailAddress & vbcrlf&_
    sBusinessTitle & vbcrlf&_
    sBusinessName & vbcrlf&_
    sCountryTitle & vbcrlf&_
    sCountryName & vbcrlf&_
    MessageName & vbcrlf&_
    MessageTitle
    ObjMail.Send
    Set ObjMail = Nothing

    But what about my HTML elements such as font size, colour, bold or not, list, etc?

    Thanks again.

    Steve
    Last edited by SteveH; 10-12-2007 at 01:25 PM.

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Code:
    sBody = "<b>Fullname</b>: " & sFullName & "<br/>" & vbcrlf &_ 
    "<b>Email</b>: " & sEmailAddress & "<br/>" & vbcrlf &_ 
    
    [etc etc]
    
    ObjMail.HTMLBody = sBody

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello Spudhead

    Thank you for your post.

    I'll try it over the weekend and post back here. Your code seems logical, so let's hope it works!

    Cheers

    Steve

  • #6
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello

    This is the code I now have:

    <%

    Dim ObjMail
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    ObjMail.BodyFormat = 0
    ObjMail.MailFormat = 0
    ObjMail.HTMLBody = sBody
    ObjMail.To = "whatever@whatever.com"
    ObjMail.CC = sEmailAddress
    ObjMail.From = sEmailAddress
    ObjMail.Subject = "Feedback"
    ObjMail.Body = sFullNameTitle & vbcrlf&_
    sFullName & vbcrlf&_
    sEmailTitle & vbcrlf&_
    sEmailAddress & vbcrlf&_
    sBusinessTitle & vbcrlf&_
    sBusinessName & vbcrlf&_
    sCountryTitle & vbcrlf&_
    sCountryName & vbcrlf&_
    MessageName & vbcrlf&_
    MessageTitle
    ObjMail.Send
    Set ObjMail = Nothing

    sBody = "<b>Fullname</b>: " & sFullName & "<br/>" & vbcrlf &_
    "<b>Email</b>: " & sEmailAddress & "<br/>" & vbcrlf &_
    "<b>Business</b>: " & sBusinessName & "<br/>" & vbcrlf &_
    "<b>Country</b>: " & sCountryName & "<br/>" & vbcrlf &_
    "<b>Message</b>: " & sMessageName & "<br/>" & vbcrlf &_

    %>

    It is generating the following error:

    Microsoft VBScript runtime error '800a01b6'

    Object doesn't support this property or method: 'HTMLBody'

    /file.asp, line 68

    I would be grateful for any further suggestions - the final part of the script does not look right to me, though I do not know why!

    Cheers again.

    Steve

  • #7
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Take out the .HTMLBody line - just set the body with the .Body line

  • #8
    New Coder
    Join Date
    Jun 2007
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi SteveH

    You really should be using CDOSYS. However, try the following:

    The code below should be in a separate .asp page, name this page how you want.

    Your main form submits to this page.

    The 'request.form("sfields")' relate to the fields on your main form.

    I have tested the code below and it works. Good luck.

    Dim ObjMail
    Dim strHTML
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    strHTML = strHTML & "<html><head><title>title goes here</title></head>"
    strHTML = strHTML & "<body>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sFullName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sEmailTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sEmailAddress")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sBusinessTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sBusinessName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sCountryTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sCountryName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"
    strHTML = strHTML & "</body></html>"


    ObjMail.From = request.form("sEmailAddress")
    ObjMail.To = "whatever@whatever.com"
    ObjMail.CC = request.form("sEmailAddress")
    ObjMail.Subject = "Feedback"
    ObjMail.BodyFormat = 0
    ObjMail.MailFormat = 0
    ObjMail.Body = strHTML
    ObjMail.Send
    Set ObjMail = Nothing


    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta http-equiv="Content-Language" content="en-us">
    <title>Home Page</title>
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    </head>
    <body>



    <p>Thank You</p>



    </body>

    </html>

  • #9
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello Bluegenel

    Many thanks for your reply - and your work!!

    I will try the script tonight and let you know how I get on, but I will probably not be able to use it on a separate page.

    manyt hanks again for all your work.

    Steve

  • #10
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello Bluegenel

    I have pasted in this:

    Dim ObjMail
    Dim strHTML
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    strHTML = strHTML & "<html><head><title>title goes here</title></head>"
    strHTML = strHTML & "<body>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sFullName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sEmailTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sEmailAddress")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sBusinessTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sBusinessName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sCountryTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sCountryName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"
    strHTML = strHTML & "</body></html>"


    ObjMail.From = request.form("sEmailAddress")
    ObjMail.To = "myemail@myinbox.com"
    ObjMail.CC = request.form("sEmailAddress")
    ObjMail.Subject = "Feedback"
    ObjMail.BodyFormat = 0
    ObjMail.MailFormat = 0
    ObjMail.Body = strHTML
    ObjMail.Send
    Set ObjMail = Nothing

    Nothing else.

    I already have a personalised 'thank you' on the site itself which works, so I have removed your HTML 'thank you' message.

    However, now there is no message sent at all to mye.mail@myinbox.com

    Please advise

    Thanks.

    Steve

  • #11
    New Coder
    Join Date
    Jun 2007
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi SteveH

    Sorry, my mistake.

    Try enclosing the script with <% at the beginning and %> at the end. As follows:

    <%

    Dim ObjMail
    Dim strHTML
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    strHTML = strHTML & "<html><head><title>title goes here</title></head>"
    strHTML = strHTML & "<body>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sFullName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sEmailTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sEmailAddress")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sBusinessTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sBusinessName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sCountryTitle")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"

    strHTML = strHTML & "<tr>"
    strHTML = strHTML & "<td>"
    strHTML = strHTML & "<font face=Arial size=2>"
    strHTML = strHTML & request.form("sCountryName")
    strHTML = strHTML & "</td>"
    strHTML = strHTML & "</tr>"
    strHTML = strHTML & "</body></html>"


    ObjMail.From = request.form("sEmailAddress")
    ObjMail.To = "myemail@myinbox.com"
    ObjMail.CC = request.form("sEmailAddress")
    ObjMail.Subject = "Feedback"
    ObjMail.BodyFormat = 0
    ObjMail.MailFormat = 0
    ObjMail.Body = strHTML
    ObjMail.Send
    Set ObjMail = Nothing

    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •