TnefMessageBody Class

A body of a TNEF message.

Definition

Namespace: MimeKit.Tnef
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public sealed class TnefMessageBody : IDisposable
Inheritance
Object    TnefMessageBody
Implements
IDisposable

Remarks

A TnefMessageBody holds the content of one of the bodies of a TnefMessage.

The content is buffered in memory when the message is loaded, so it may be read any number of times.

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;
}
                  

Properties

Encoding Get the text encoding of the content.
Format Get the format of the body.
Length Get the length of the content.
Tag Get the tag of the property that the body was read from.

Methods

Dispose Release all resources used by the TnefMessageBody object.
Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetText Get the content as text.
GetType Gets the Type of the current instance.
(Inherited from Object)
OpenDecodedRead Open a stream for reading the decoded content.
OpenRead Open a stream for reading the raw content.
ToString Returns a string that represents the current object.
(Inherited from Object)

See Also