public GetTextBody ( TextFormat format ) : string | ||
format | TextFormat | The desired text format. |
return | string |
public string GetTextBody (TextFormat format)
{
var multipart = Body as Multipart;
if (multipart != null) {
string text;
if (TryGetMultipartBody (multipart, format, out text))
return text;
} else {
var body = Body as TextPart;
if (body != null && body.IsFormat (format))
return body.Text;
}
return null;
}
public Message(MimeMessage inMessage) { MessageId = inMessage.MessageId; From = inMessage.From.InternetAddressListToDictionary(); Cc = inMessage.Cc.InternetAddressListToDictionary(); Bcc = inMessage.Bcc.InternetAddressListToDictionary(); Date = inMessage.Date; Subject = inMessage.Subject; MessageText = inMessage.GetTextBody(TextFormat.Text); if (string.IsNullOrEmpty(MessageText)) { try { MessageText = HtmlToText.ConvertHtml(inMessage.HtmlBody).Replace("\r", "").Replace("\n", ""); } catch(Exception ex) { MessageText = "-"; } } }