MailBee.NET Objects 7.2

Header Class

Provides properties for examining or setting the name or the value of a single field of the headers section of a MIME part.

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

System.Object
   MailBee.Mime.Header

public class Header

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.

Remarks

Each MIME part of the message (including the message itself which is actually a root MIME part) have header section containing of some name-value pairs. Header class represents such a pair. To access the entire collection of MIME part headers, use MimePart.Headers property. To access headers of the message itself, it's easier to use MailMessage.Headers property.

Some examples of header names and values are represented below:

NameValue
FromJohn Doe <jdoe@hisdomain.com> (XXX Company)
ToKaty Smith <k.smith@herdomain.com>
Cctechsupport@ourdomain.com
SubjectMeeting request.
Content-Typemultipart/mixed; boundary="--511842ECA261D"
DateThu, 8 Dec 2005 19:27:22 -0500
X-Priority3 (Normal)

Example

This sample loads the message from .EML file and shows all the message headers.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// The actual code (put it into a method of your class)

// Load the message from file.
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");

// For every header...
foreach (Header hdr in msg.Headers)
{
    // Show the header.
    Console.WriteLine(string.Format("Name: {0}; Value: {1}", hdr.Name, hdr.Value));
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

' The actual code (put it into a method of your class)

' Load the message from file.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")

' For every header...
For Each hdr As Header In msg.Headers
    ' Show the header.
    Console.WriteLine(String.Format("Name: {0}; Value: {1}", hdr.Name, hdr.Value))
Next

Requirements

Namespace: MailBee.Mime

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

Header Members | MailBee.Mime Namespace | RawHeader | MimePart