本文整理汇总了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);
}