Calendar - mail mapping.

This commit is contained in:
Burak Kaan Köse
2026-02-10 21:35:55 +01:00
parent 10dd42b63f
commit 870a5e2bf6
10 changed files with 818 additions and 21 deletions
@@ -48,9 +48,22 @@ public class HtmlPreviewVisitor : MimeVisitor
protected override void VisitMultipartAlternative(MultipartAlternative alternative)
{
// walk the multipart/alternative children backwards from greatest level of faithfulness to the least faithful
// Prefer rich body alternatives first, and only fall back to calendar text if nothing else exists.
for (int i = alternative.Count - 1; i >= 0 && Body == null; i--)
{
if (IsCalendarText(alternative[i]))
continue;
alternative[i].Accept(this);
}
for (int i = alternative.Count - 1; i >= 0 && Body == null; i--)
{
if (!IsCalendarText(alternative[i]))
continue;
alternative[i].Accept(this);
}
}
protected override void VisitMultipartRelated(MultipartRelated related)
@@ -241,6 +254,10 @@ public class HtmlPreviewVisitor : MimeVisitor
Body = converter.Convert(entity.Text);
}
private static bool IsCalendarText(MimeEntity entity)
=> entity is TextPart textPart &&
textPart.ContentType?.MimeType?.Equals("text/calendar", StringComparison.OrdinalIgnoreCase) == true;
protected override void VisitTnefPart(TnefPart entity)
{
// extract any attachments in the MS-TNEF part