Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty HtmlBody for some Apple Mail messages (sent from iOS) #963

Closed
alex-jitbit opened this issue Oct 16, 2023 · 2 comments
Closed

Empty HtmlBody for some Apple Mail messages (sent from iOS) #963

alex-jitbit opened this issue Oct 16, 2023 · 2 comments

Comments

@alex-jitbit
Copy link

Describe the bug
Both HtmlBody and TextBody return null for some Apple Mail messages. However the bodies can be retrieved by enumerating BodyParts manually like this:

body = ((TextPart)msg.BodyParts.FirstOrDefault(b => b is TextPart && b.ContentType.MimeType == "text/html"))?.Text;
  • MimeKit Version: 4.2.0

To Reproduce
I've attached an .eml file and cleared out all the sensitive info from it.

Expected behavior
HtmlBody should be set to first BodyPart maybe?

Additional context
I totally understand that the message hierarchy is kinda, uhm, malformed. However maybe you would like to add a workaround b/c this is from iOS 16 Mail app which is becoming popular.
test321.zip

@alex-jitbit alex-jitbit changed the title Empty HtmlBody for some Apple Mail messages Empty HtmlBody for some Apple Mail messages (sent from iOS) Oct 16, 2023
@jstedfast
Copy link
Owner

I've taken a look at the message and it appears that the mime structure is as follows:

  • multipart/alternative
    • multipart/mixed
      • text/html
      • text/html
      • text/html

It's a pretty bizarre structure that I'm not entirely sure how to interpret.

Expected behavior
HtmlBody should be set to first BodyPart maybe?

Maybe? Technically speaking, the entire multipart/mixed is the "body". Each child of a multipart/alternative is supposed to be an option to use as the message body, each being an "alternative" to its siblings. In this case, the multipart/mixed is the only child of the multipart/alternative.

jstedfast added a commit that referenced this issue Nov 4, 2023
This cleans up the old logic internal to MimeMessage for getting the
message body in a specified format to the Multipart subclasses.

Should also fix issue #963
@jstedfast
Copy link
Owner

This is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants