2

I am having an issue testing alternate views while sending HTML E-Mails. I am creating sending the mail message as plain text, but I include an HTML alternate view. I have tried using several e-mail clients, but I have been unable to see the plain text version. My main concern is that someone who does use a plain text only client won't see it correctly. See below for code:

MailMessage message = new MailMessage();

message.To.Add("email");
message.From = new MailAddress("fromaddress");
message.Subject = "subject"
//Plain text version of e-mail
message.Body = _formattedPlainText;
message.IsBodyHtml = false;

AlternateView htmlView = CreateHTMLView();

message.AlternateViews.Add(htmlView);
//message.AlternateViews.Add(plainTextView);

smtp.Send(message);

private AlternateView CreateHTMLView()
{
    AlternateView htmlView =  AlternateView.CreateAlternateViewFromString(_formattedHTML, null, System.Net.Mime.MediaTypeNames.Text.Html);

    //Code for adding embedded images...

    return htmlView;
}

Is there reason to believe the plain text version isn't being received or are there any clients you know that definitely can only receive plain text e-mails?

Thanks in advance

UPDATE:

You can force plain text in GMAIL by pressing the options arrow and selecting the option "Message Text Garbled?"

1
  • Most modern readers will default to reading in HTML. You could try opening it in Pine on a Linux system, which I believe will discard the html view. There might be an easy way to force Outlook or another app to view only in plain text (for testing), but I'm not sure of the options. Commented Nov 11, 2011 at 20:20

2 Answers 2

2

Is there reason to believe the plain text version isn't being received or are there any clients you know that definitely can only receive plain text e-mails?

No, and PINE.

You could use the mail command in any *nix OS to read email. It will only display email in text format.

UPDATE

A guy here, claims that GMAIL ONLY displays emails in plain text if given the option. I find that an awkward default choice from Google if that's still the case.

Sign up to request clarification or add additional context in comments.

2 Comments

@DarkBobG: haha I love PINE, is my mail client of choice in Linux. Use it since Slackware 95 :)
Thanks for the quick answer. Gmail definitely isn't choosing the plain text version for me. I am going to see if there are any settings that I can force it into plain text. Still looking for the easiest client with a quick setup. I've seen the source of the e-mail and it definitely using the correct mime-type from what I can tell: Content-Type: multipart/alternative; boundary="--boundary_0_510b3ccc-889b-4b81-9e66-d6fd828a410b"
2

Through some experimentation I have had best results this way:

Set up two alternate views, one HTML and one plain text. Then, leave the MailMessage.Body alone (default/undefined) and leave the MailMessage.IsBodyHtml at default. My code segment:

                myMessage.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(HtmlMessage, new System.Net.Mime.ContentType("text/html")));
        myMessage.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(TextMessage, new System.Net.Mime.ContentType("text/plain")));
    //    myMessage.Body = HtmlMessage;
    //    myMessage.IsBodyHtml = true;
        myClient.UseDefaultCredentials = false;
        NetworkCredential credentials = new NetworkCredential("xxxx","xxxxx");
        myClient.Credentials = credentials;
        myClient.DeliveryMethod = SmtpDeliveryMethod.Network;

I have tested this with messages sent to Windows Outlook clients and to Mac users, and it seems to work just fine. The email client software chooses the view. I still need to test how this works for clients such as webmail apps. Your mileage may vary.

Bob

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.