Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

system.net.mail isbodyhtml = true vs two AlternateViews pros/cons

Here is the use case:

I am making an app that will email HTML Newsletters. The app will also email a plain text version of the newsletter as an alternate view. The way I see it there are two ways of going about this when using the system.net.mail namespace. What are the pro/cons of these two ways, or is there a another way that I am missing? Thank you.

Dim m As New MailMessage
' One alternate view'
m.IsBodyHtml = True
m.Body = HTMLString
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plaintextstring), Nothing, "text/plain")
' OR two alternate views without specifying the body '
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plaintextstring), Nothing, "text/plain")
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(HTMLstring), Nothing, "text/html")
like image 209
Solracnapod Avatar asked Dec 04 '25 10:12

Solracnapod


1 Answers

nope these are the two ways of doing it, you might also want to set the following for the alternate views as there can be weird side effects across different clients if not.

AlternativeObject.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
like image 126
keyoke Avatar answered Dec 08 '25 12:12

keyoke