C# Send both HTML and Text email - most elegant?

前端 未结 6 1386
余生分开走
余生分开走 2021-01-30 23:17

Is is best practice to send both HTML and Text email?

If I only send HTML what are the dangers?

I\'m thinking something like this below from

http://johnn

相关标签:
6条回答
  • 2021-01-30 23:26

    Another reason to send both is that many mailservers mark emails that only contain HTML content as spam. You don't want all your emails to be put in the junk folder.

    0 讨论(0)
  • 2021-01-30 23:28

    I would say that, in today's world, the "best-practice" approach would be to ensure that you send your message as both plain text and HTML (if you really want to send HTML email messages).

    Oh, and make sure you do actually send the content in the plain text view, rather than a single sentence saying "You must use an email client that supports HTML messages". Google Mail takes this approach, and it seems to work perfectly, allowing "rich" views on full-fledged PC clients, whilst also allowing "minimal" views on more restricted devices (i.e. Mobile/Cell phones).

    If you want to take a purist's view, you wouldn't be sending HTML emails at all, nor would you ever "attach" a binary file to an email. Both corruptions of the original email standard, which was only ever originally intended for plain text. (See some people's opinions of this here and here)

    However, in the pragmatic modern-day real world, HTML email is very real, and very acceptable. The primary downside to sending HTML email is whether the recipient will see the email in the way that you intended them to see it. This is much the same problem that web designers have battled with for years; getting their websites to look "just right" in all possible browsers (although it's significantly easier today than it was many years ago).

    Similar to ensuring that a website functions correctly without requiring Javascript, by sending your emails as both HTML and Plain Text, you'll ensure that your emails degrade gracefully so that people reading their emails on (for example) small mobile devices (something that's becoming more and more prevalent these days - and which may or may not be capable of rendering a complete HTML email) can still read your email content without issue.

    0 讨论(0)
  • 2021-01-30 23:31

    If you only send HTML, then anyone reading email on a text-only device will have trouble.

    For example, I suspect many low-end mobile devices are capable of reading email but not displaying full HTML.

    I would say it's best practice to either send text-only, or text and HTML.

    I don't see why you're catching a bunch of exceptions only to rethrow the same exception type with a different message, by the way - the original message may well be more descriptive.

    0 讨论(0)
  • 2021-01-30 23:36

    Sharing my experience with sending both HTML and text in one email: I have created an email message that has 2 views: text and html using C# AlternateView classes.

    What did I get?

    On Mac, tested on High Sierra: Apple Mail app was showing the Html. If the order of messages is reversed: Html - text then Apple Mail will show the text view. The conclusion: Apple Mail is using the last view as default.

    In Windows, Outlook 2010: Microsoft Outlook by default is using the Html view. The order of views in the email doesn't matter: html,text; text,html;

    If for some reason you selected a setting to show incoming messages as a text then the Html version of your email will be converted into the text by Outlook. Even so you send the text version of your email (which might be slightly different from the HTML version and was formatted to look pretty) it won't be used.

    So you don't need to send the text version of your email if you know that your clients use Outlook and Html version is selected as default.

    Mozilla Thunderbird respects your settings and shows the correct Html or text version of your email. It works correctly on Mac and in Windows

    Hope it helps

    0 讨论(0)
  • 2021-01-30 23:42

    Several email clients will use the last AlternateView that was added to the AlternateViews.

    So if you prefer to have your mail displayed as HTML, be sure to add that last.

    I have notice this for IOS mail and OSX mail, while Android Email seems to prefer HTML if it is available. I am not sure for which versions this holds, and the behaviour is often user-configurable, but in my experience these were the defaults.

    0 讨论(0)
  • 2021-01-30 23:48

    I think yes, the best practice is to send both. The reason (c&p from wikipedia):

    The default e-mail format according to RFC 2822 is plain text. Thus e-mail software isn't required to support HTML formatting. Sending HTML formatted e-mails can therefore lead to problems at the recipient's end if it's one of those clients that don't support it. In the worst case, the recipient will see the HTML code instead of the intended message.

    0 讨论(0)
提交回复
热议问题