Web Connection
Issue viewing emails sent with both HTML and plain text sections
Gravatar is a globally recognized avatar based on your email address. Issue viewing emails sent with both HTML and plain text sections
  Mike McDonald
  All
  Feb 18, 2019 @ 11:21am

Rick -

I've been testing out sending emails to a Gmail account, and it is working fine for either plain text emails or HTML emails. However, if I send an HTML email that also includes a plain text section (by setting wwSMTP::cAlternateText), then Gmail only displays the plain text portion (although the HTML section is there when viewing the 'source' of the email).

Apparently this is because the plain text 'multipart' section is being added to the email content after the HTML section, and the spec says that the order of the sections is significant, and the last recognized section should be used by the email client.

The following is from section 7.2.3 of an IETF.org document..

As with multipart/mixed, the order of body parts is significant. In this case, the alternatives appear in an order of increasing faithfulness to the original content. In general, the best choice is the LAST part of a type supported by the recipient system's local environment.

I found the above through a StackOverflow discusssion.

I wanted to temporarily subclass wwSMTP and test out switching the multipart sections around, but that isn't handled within wwSMTP.prg itself (except for the SendMailClassic function). Instead the sections are apparently set up by the .NET Westwind.wwSmtp object.

This behavior also depends on the type of email client you are using - it seems some of them will display the HTML version even if a plain text section appears last, but Gmail for one will only show the plain text version in this case.

For now I'm just not setting the cAlternateText property and so I see the HTML version as expected.

- Mike McDonald

Gravatar is a globally recognized avatar based on your email address. re: Issue viewing emails sent with both HTML and plain text sections
  Rick Strahl
  Mike McDonald
  Feb 19, 2019 @ 05:42pm

Don't have an answer for you - i'll take a look and see if I can reverse the order of how the parts are added but if I remember right the way it works in the .NET component that I use for this is that you have a main section and an alternate section and those get added internally. So while multiple alternates could be controlled the main one will always be first I think.

I'll take a look.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Issue viewing emails sent with both HTML and plain text sections
  Mike McDonald
  Rick Strahl
  Feb 20, 2019 @ 08:44pm

Rick -

Not a problem - I didn't realize this was based on something out of your control.

I'm fine with not including the plain text - the HTML version shows up just fine.

- Mike McDonald

© 1996-2019