Urgent - Send mail with plain view and html view
Hi,
I need to send a mail in both formats together (plain text + HTML) so that if on any email client(like Outlook, Thunderbird etc) HTML view is disabled, the plain text should be displayed.
Things that are already tried:
While sending the mail I am creating an "AlternateView" for both plain Text and HTML and assigning it to the Message object. Below shown is the code:
//////////////////////////////////////////////////////////////////
SmtpClient smtpClient = new SmtpClient();
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(fromAddress, toAddress);
message.Subject = subject;
// Add the alternate body to the message (Plain text message) . The parameter "body" contains the plain text.
AlternateView plainView = AlternateView.CreateAlternateViewFromString(body);
plainView.ContentType = new ContentType("text/plain");
// Add the alternate body to the message (HTML message) . The parameter "htmlBody" contains the HTML text
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBo dy);
htmlView.ContentType = new ContentType("text/html");
message.AlternateViews.Add(plainView);
message.AlternateViews.Add(htmlView);
smtpClient.Send(message);
//////////////////////////////////////////////////////////////////
The mail was sent successfully but the problem here is with testing Plain View. In Outlook I selected the option to "Read all Std. Mails in Plain Text" but contents of the mail is HTML conversion into normal text but not the Plain Text view. In mail header the content type shows : multipart/alternative.
This functionality was even tested on Thunderbird on Windows as well as on Apple mail client but is not working as expected.
Appreciate any help to display Plain + HTML view on email client.
|