|
Setting and getting message headers |
|
You can add custom headers to a MimeMessage by invoking the AddHeader method and passing it a MimeHeader instance. Custom header names generally start with an "X" followed by a hyphen and a header name.
Example
This example first sets a custom header then displays the header value.
[C#]
MimeHeader agent = new MimeHeader("X-Mailer", "Microsoft Outlook");
message.AddHeader(agent);
// displays Microsoft Outlook
Console.WriteLine(message.GetHeaderValue("X-Mailer"));
[Visual Basic]
Dim agent As MimeHeader = Nothing
agent = New MimeHeader("X-Mailer", "Microsoft Outlook")
message.AddHeader(agent)
' displays Microsoft Outlook
Console.WriteLine(message.GetHeaderValue("X-Mailer"))