HeaderCollectionItem Property (String) |
Gets or sets the header value by the header name.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public string this[
string name
] { get; set; }
Public Default Property Item (
name As String
) As String
Get
Set
Parameters
- name
- Type: SystemString
The name of the header. Some examples: To, Content-Type, X-UIDL.
Property Value
Type:
String
The string representing the value of the header with the specified name, or a null reference (
Nothing in Visual Basic) if no such header exists in the collection.
Remarks
If the collection contains several headers with the specified name, the first matching header will be returned.
To access multiple headers with the same name, the developer should use
Items(String) method.
Examples This sample loads the message from .EML file and displays the value of
Subject: header of the message.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
string subjectHeaderValue = msg.Headers["Subject"];
if (subjectHeaderValue != null)
{
Console.WriteLine("Message subject: " + subjectHeaderValue);
}
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
Dim subjectHeaderValue As String = msg.Headers("Subject")
If Not subjectHeaderValue Is Nothing Then
Console.WriteLine("Message subject: " & subjectHeaderValue)
End If
See Also