SocketTools .NET Edition

MailMessage.GetHeader Method (Int32, String, String)

Return the value of a header field in the specified message part.

[Visual Basic]
Overloads Public Function GetHeader( _
   ByVal messagePart As Integer, _
   ByVal headerName As String, _
   ByRef headerValue As String _
) As Boolean
[C#]
public bool GetHeader(
   int messagePart,
   string headerName,
   ref string headerValue
);

Parameters

messagePart
An integer which specifies the message part.
headerName
A string which specifies the name of the header field.
headerValue
A string passed by reference which will contain the value of the header field when the method returns.

Return Value

This method returns a Boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

The GetHeader method is used to retrieve the value for a specific header in the specified message part. If the header field exists, the method will return true and the headerValue argument will contain the header value. If the header does not exist, the method will return false.

If there are multiple headers with the same name, the first value will be returned. To enumerate all of the headers in a message, including duplicate header fields, use the GetFirstHeader and GetNextHeader methods.

See Also

MailMessage Class | SocketTools Namespace | MailMessage.GetHeader Overload List | AddHeaders Method | SetHeader Method