Send Multipart Email - Plain and HTML

Posted on 2009-02-11
Last Modified: 2012-05-06
Trying to send a multipart email and not sure if it is working right.  
It is part of an asp website.  
Currently being sent by CDOSYS with:

objMail.TextBody = "This is a plain text message"
objMail.HTMLBody = HTML

Is this the correct method?  Or should it be done some other way.
How do I tell if it is working.  
Any mail client I have sent it to is showing the html.  
When I change Outlook 2003 to show Plain Text Email it just seems to strip the html tags out of the html version rather than showing the Plain Text Version.  
Should both parts be in the email headers?  Or how do I check that both parts have actually been sent?
Question by:harris9999
    LVL 9

    Expert Comment

    Looks like you are declaring the email content as plain text and then over-riding this with a declaration that the content is HTML. Strip out the line objMail.HTMLBody = HTML and try sending.
    LVL 9

    Expert Comment

    LVL 9

    Expert Comment

    Code Outline Below Helps you send both version of eMails.

    You can change the code according to your need.

    Hope this helps.
    'We start by creating a mail object and a configuration object to use 
    'with it:
      Set oCdoMail = Server.CreateObject("CDO.Message")
      Set oCdoConf = Server.CreateObject("CDO.Configuration")
    'Set the configuration object up as shown below. You might have to 
    'change the SMTP server item from "localhost" to point to your web 
    'hosts SMTP server. The default port is 25, which you may also have to 
    'change - again, check with your web host.
      sConfURL = ""
      with oCdoConf
        .Fields.Item(sConfURL & "sendusing") = 2
        .Fields.Item(sConfURL & "smtpserver") = "localhost"
        .Fields.Item(sConfURL & "smtpserverport") = 25
      end with
    'Now we can set up our recipients. You can send to multiple recipients 
    'by seperating addresses with a semicolon, as shown with the To 
    'property below:
      with oCdoMail
        .From = ""
        .To = ";"
        .CC = ""
        .BCC = ""
      end with
    'Set the Subject and Body text and we're almost there. To send plain 
    'text email, use the TextBody method. To send HTML email, use the 
    'HTMLBody method.
    'You can also add an attachment to your message by using the 
    'AddAttachment method:
      with oCdoMail
        .Subject = "My message subject"
        .TextBody = "This is a plain text email"
        .HTMLBody = "<b>This is an HTML email</b>"
        .AddAttachment = "C:\Inetpub\wwwroot\"
      end with
    'And that's just about it, all we need to do now is bind the 
    'configuration to the CDO Message and send the email:
      oCdoMail.Configuration = oCdoConf
      Set oCdoConf = Nothing
      Set oCdoMail = Nothing

    Open in new window

    LVL 3

    Author Comment

    Thats exactly how I am sending the email at the minute.  
    But I'm not sure if both the text/plain bit and the HTML are being sent in the one message.  

    It is a sort of mailing application and it is good practice to send both versions in the one email.  
    The mail is being sent and is being received fine.  And the html is showing.  But how do I know if the plain part was sent as well as the html part.  
    LVL 9

    Accepted Solution

    It may be difficult to view all the parts of your e-mail message at the same time. View|Source may only show the HTML portion of the message. Without Outlook 2000, the only way I can view both parts of the message is to forward an HTML message to a non-existent e-mail address. When the bounced message comes back I'm able to see each part of the multipart message.

    Hope this helps

    LVL 3

    Author Comment

    I had a good search on the internet and it mentioned that Thunderbird supported multipart emails.  So downloaded and set up and account and it was able to show the plain text version when I put it to Plain Text mode.  and the HTMl in normal mode so I'm now happy that my code was working correctly.  

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    The viewer will learn how to dynamically set the form action using jQuery.

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now