Tnef MessageHtml Body Property
Get the HTML body of the message.
Definition
Namespace: MimeKit.Tnef
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
The HTML body, or if the message does not have one.
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public TnefMessageBody? HtmlBody { get; }Property Value
TnefMessageBodyThe HTML body, or if the message does not have one.
Remarks
Gets the HTML body of the message, from the BodyHtml property.
Example
C#
public static string GetBodyText (TnefMessage tnef, out TnefMessageBodyFormat format)
{
// A TNEF message may have a plain-text body, an HTML body and/or a compressed RTF body.
if (tnef.HtmlBody != null) {
format = tnef.HtmlBody.Format;
return tnef.HtmlBody.GetText ();
}
if (tnef.RtfBody != null) {
format = tnef.RtfBody.Format;
// OpenDecodedRead () decompresses the RTF; OpenRead () would return the compressed bytes.
using (var rtf = tnef.RtfBody.OpenDecodedRead ())
using (var reader = new StreamReader (rtf, Encoding.ASCII))
return reader.ReadToEnd ();
}
if (tnef.TextBody != null) {
format = tnef.TextBody.Format;
return tnef.TextBody.GetText ();
}
format = TnefMessageBodyFormat.Text;
return string.Empty;
}