Tnef MessageText Body Property
Get the plain text body of the message.
Definition
Namespace: MimeKit.Tnef
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
The plain text body, or if the message does not have one.
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public TnefMessageBody? TextBody { get; }Property Value
TnefMessageBodyThe plain text body, or if the message does not have one.
Remarks
Gets the plain text body of the message, from the Body property or, if the
message does not have that property, from the legacy Body attribute.
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;
}