There are two ways to get the message body:
1.
, , .
:
var message = folder.GetMessage (uid);
var message = folder.GetMessage (index);
UniqueId . Fetch, , , , UniqueId , MessageSummaryItems.UniqueId :
var messages = folder.Fetch (0, -1, MessageSummaryItems.UniqueId |
MessageSummaryItems.Envelope | ...);
, , .
MessageReader, MimeKit GitHub.
, MimeMessage.
2. ,
, .
, , MessageSummaryItems.BodyStructure Fetch. :
var messages = folder.Fetch (0, -1, MessageSummaryItems.Envelope |
MessageSummaryItems.BodyStructure);
(, , , , ).
BodyStructure , msg.Body.
msg.Body BodyPart, . 2 BodyPartMultipart BodyPartBasic. as is, , :
var multipart = msg.Body as BodyPartMultipart;
if (multipart != null) {
} else {
}
BodyPartMultipart:
foreach (var part in multipart.BodyParts) {
}
2 BodyPartBasic, : BodyPartText BodyPartMessage. A BodyPartText - MIME- ( , MIME- text/*), BodyPartMessage ( MIME message/rfc822).
MIME , , MIME, MIME, .
TextBody HtmlBody IMessageSummary text/plain text/html .
, , , (, , , MIME).
, HTML, HTML MIME ( multipart/related), HtmlBody , .
, , ImapClientDemo MailKit GitHub. MainWindow.cs.