سؤال

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")
هل كانت مفيدة؟

المحلول

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;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top