MailBee.NET Objects 4.0

HeaderCollection.Exists Method 

Checks whether a header with the given name exists in the collection.

public bool Exists(
   string name
);

Parameters

name
The name of the header.

Return Value

true if the collection contains the header with the specified name; otherwise, false.

Example

This sample creates the new message and adds a custom header if it does not yet exist.

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

MailMessage msg = new MailMessage();
if (!msg.Headers.Exists("X-MyHeader"))
{
    msg.Headers.Add("X-MyHeader", "some value for the header", false);
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

Dim msg As New MailMessage
If (Not msg.Headers.Exists("X-MyHeader")) Then
    msg.Headers.Add("X-MyHeader", "some value for the header", False)
End If

See Also

HeaderCollection Class | MailBee.Mime Namespace | Header | MailMessage