HeaderCollectionItems Method |
Returns the collection of headers having the given name.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public HeaderCollection Items(
string name
)
Public Function Items (
name As String
) As HeaderCollection
Parameters
- name
- Type: SystemString
The name of the header.
Return Value
Type:
HeaderCollection
A
HeaderCollection object containing the headers having the specified name, or
a null reference (
Nothing in Visual Basic) if such headers do not exist in the collection.
Remarks This method should be used if the mail message contains several headers with the same name and the developer
wants to examine them all. In other cases, it's easier to use
ItemString property.
Examples This sample loads the message from .EML file and displays "Received" headers of the message.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
HeaderCollection receivedHeaders = msg.Headers.Items("Received");
if (receivedHeaders != null)
{
foreach (Header hdr in receivedHeaders)
{
Console.WriteLine(string.Format("{0}: {1}", hdr.Name, hdr.Value));
}
}
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
Dim receivedHeaders As HeaderCollection = msg.Headers.Items("Received")
If Not receivedHeaders Is Nothing Then
For Each hdr As Header In receivedHeaders
Console.WriteLine(String.Format("{0}: {1}", hdr.Name, hdr.Value))
Next
End If
See Also