Tnef MessageRtf Body Property
Get the compressed RTF body of the message.
Definition
Namespace: MimeKit.Tnef
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
The compressed RTF body, or if the message does not have one.
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public TnefMessageBody? RtfBody { get; }Property Value
TnefMessageBodyThe compressed RTF body, or if the message does not have one.
Remarks
Gets the compressed RTF body of the message, from the RtfCompressed property.
Use OpenDecodedRead to read the decompressed RTF.
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;
}