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.

Leafs:
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 .

System.Object
   MessagePart

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.

Example

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.
--frontier
Content-Type: text/plain

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

PGh0bWw+CiAgPGHLYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
--frontier--
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

Requirements

Namespace: OpenPop.Mime

Assembly: OpenPop (in OpenPop.dll)

See Also

MessagePart Members | OpenPop.Mime Namespace