本文整理匯總了C#中MimeKit.MimeMessage.GetTextBody方法的典型用法代碼示例。如果您正苦於以下問題:C# MimeMessage.GetTextBody方法的具體用法?C# MimeMessage.GetTextBody怎麽用?C# MimeMessage.GetTextBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MimeKit.MimeMessage
的用法示例。
在下文中一共展示了MimeMessage.GetTextBody方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Message
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 = "-";
}
}
}
示例2: AssertEmailsAreEqual
private static void AssertEmailsAreEqual(SMTP.EMail actual, MimeMessage msg)
{
var body = msg.GetTextBody (MimeKit.Text.TextFormat.Text);
var expected = new SMTP.EMail (
string.IsNullOrEmpty (body) ? new string[0] : new[] { body },
msg.Subject,
msg.From.Select (s => s.ToString ()),
msg.To.Select (s => s.ToString ()),
msg.Headers
.Select (h => h.Field + ": " + h.Value)
.Concat (msg.Body.Headers.Select (h => h.ToString ())));
AssertEmailsAreEqual (actual, expected);
}