Class

InternetHeaders


Description

Used to manage HTTP and Email headers.

Methods

Name

Parameters

Returns

Shared

AddHeader

Name As String, Value As String

CommaSeparatedValues

Name As String

String

Count

Integer

Name

Index As Integer

String

NameCount

Name As String

Integer

RemoveAllHeaders

RemoveHeader

Name As String, index As Integer = -1

Source

String

Value

Name As String, index As Integer = -1

String

ValueAt

index As Integer

String

Method descriptions


InternetHeaders.AddHeader

AddHeader(Name As String, Value As String)

Adds a new header.

' populate a email message
Var mail As New EmailMessage
mail.FromAddress = FromAddressField.Text
mail.Subject = SubjectField.Text
mail.BodyPlainText = BodyField.Text
mail.BodyHTML = HtmlField.Text
mail.Headers.AddHeader("X-Mailer","Example SMTP Demo")

InternetHeaders.CommaSeparatedValues

CommaSeparatedValues(Name As String) As String

Returns the Value of the header corresponding to the passed Name.

The following example returns the value of the "X-Mailer" header.

' mail is an EmailMessage
Var s As String
s = mail.Headers.CommaSeparatedValues("X-Mailer")

InternetHeaders.Count

Count As Integer

Returns the number of headers as an Integer.

Var i As Integer = mail.Headers.Count

InternetHeaders.Name

Name(Index As Integer) As String

Returns as a String the name of the header specified by its index. Index is zero-based.

This example reads the first header.

Var s As String
s = mail.Headers.Name(0)

InternetHeaders.NameCount

NameCount(Name As String) As Integer

Returns as an Integer the number of headers with the name passed to it.

Internet headers can have multiple headers with the same name.

Var i As Integer
i = mail.Headers.NameCount("X-Mailer").ToString

InternetHeaders.RemoveAllHeaders

RemoveAllHeaders

Removes all headers.

This example removes all the headers.

Var mail As New EmailMessage
mail.Headers.RemoveAllHeaders

InternetHeaders.RemoveHeader

RemoveHeader(Name As String, index As Integer = -1)

Removes the specified header.

mail.Headers.RemoveHeader("X-Mailer")

InternetHeaders.Source

Source As String

Returns a String containing the raw source text of the headers.

The Name and Value are separated by a colon for each header and the headers are delimited by an EndOfLine.

This example retrieves the internet headers and displays them in a TextArea.

Var mail As New EmailMessage
TextArea1.Text = mail.Headers.Source

InternetHeaders.Value

Value(Name As String, index As Integer = -1) As String

Returns a String containing the value of the specified header. More than one header can have the same name.

Var s As String
s = mail.Headers.Value("X-Mailer")
Var s As String
s = mail.Headers.Value(1)
Var s As String
s = mail.Headers.Value("X-Mailer", 1)

InternetHeaders.ValueAt

ValueAt(index As Integer) As String

Returns the header at the specified index.

Var s As String
s = mail.Headers.ValueAt(1)

Compatibility

All project types on all supported operating systems.