OpenPop.NET POP3 Library Documentation

MessagePart Class

A MessagePart is a part of an email message used to describe the whole email parse tree.

Email messages are tree structures:
Email messages may contain large tree structures, and the MessagePart are the nodes of the this structure.
A MessagePart may either be a leaf in the structure or a internal node with links to other MessageParts.
The root of the message tree is the Message class.

If a MessagePart is a leaf, the part is not a MultiPart message.
Leafs are where the contents of an email are placed.
This includes, but is not limited to: attachments, text or images referenced from HTML.
The content of an attachment can be fetched by using the Body property.
If you want to have the text version of a MessagePart, use the GetBodyAsText method which will
convert the Body into a string using the encoding the message was sent with.

Internal nodes:
If a MessagePart is an internal node in the email tree structure, then the part is a MultiPart message.
The MessageParts property will then contain links to the parts it contain.
The Body property of the MessagePart will not be set.

See the example for a parsing example.
This class cannot be instantiated from outside the library.

For a list of all members of this type, see MessagePart Members .


public class MessagePart

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.


This example illustrates how the message parse tree looks like given a specific message

The message source in this example is:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="frontier"

This is a message with multiple parts in MIME format.
Content-Type: text/plain

This is the body of the message.
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

The tree will look as follows, where the content-type media type of the message is listed
- Message root
  - multipart/mixed MessagePart
    - text/plain MessagePart
    - application/octet-stream MessagePart
It is possible to have more complex message trees like the following:
- Message root
  - multipart/mixed MessagePart
    - text/plain MessagePart
    - text/plain MessagePart
    - multipart/parallel
      - audio/basic
      - image/tiff
    - text/enriched
    - message/rfc822
But it is also possible to have very simple message trees like:
- Message root
  - text/plain


Namespace: OpenPop.Mime

Assembly: OpenPop (in OpenPop.dll)

See Also

MessagePart Members | OpenPop.Mime Namespace