Closed firat-plutoflume closed 5 months ago
The expected behavior is really going to depend on the particular message you are parsing.
That said, it looks like you took it upon yourself to debug this issue and find the cause (thanks!).
It definitely looks like that logic could use some improvement.
Sorry @jstedfast I was away for a while and I'm only able to test latest release(4.4.0), I still have problems getting MimeMessage.BodyParts
correctly, it looks like text/plain
and text/html
body parts are skipped when we set depth to 1.
Here is what I get in debugger with this change:
Here is what I was getting before:
Set MaxMimeDepth = 2
When MaxMimeDepth = 1, the multipart/alternative is treated like a MimePart instead of a Multipart.
Describe the bug We are trying to minimize our cpu and memory usage by only extracting first level of attachments/emails under an email.
MaxMimeDepth
option seems to designed for this, but when I passnew ParserOptions() { MaxMimeDepth = 1 }
toMimeMessage.Load()
it doesn't set HtmlBody and TextBody fields (although I can see them underBodyParts
collection)I believe the reason is we get
MimePart
instead of aTextPart
here whendepth=MaxMimeDepth
, then it fails check in one of these places (just guessing):Note: I'm not 100% sure if this is intentional or a 'bug', if not could you please guide how to extract only first level of attachments and have the body fields?
Platform (please complete the following information):
To Reproduce Steps to reproduce the behavior:
MimeMessage.Load(new ParserOptions() { MaxMimeDepth = 1 }, stream)
text/html
andtext/plain
typesMimeMessage.TextBody
andMimeMessage.HtmlBody
are nullExpected behavior I expect
MimeMessage.TextBody
andMimeMessage.HtmlBody
to be not null when there are body parts withtext/html
andtext/plain
typesCode Snippets If applicable, add code snippets to help explain your problem.
Additional context Add any other context about the problem here.