GetTextBody() публичный Метод

Gets the text body in the specified format.
Gets the text body in the specified format, if it exists.
public GetTextBody ( TextFormat format ) : string
format TextFormat The desired text format.
Результат string
Пример #1
0
 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
0
		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);
		}