CMailMessage::GetFirstHeader Method  
 
BOOL GetFirstHeader(
  LPTSTR lpszHeader,  
  INT cchMaxHeader,  
  LPTSTR lpszValue,  
  INT cchMaxValue  
);
BOOL GetFirstHeader(
  CString& strHeader,  
  CString& strValue  
);

The GetFirstHeader method returns the header field name and value for the first header in the current message part. This method is typically used in conjunction with GetNextHeader to enumerate all of the message header fields and their values in the current message part.

Parameters

lpszHeader
A pointer to a string buffer that will contain the the name of the first header in the current message part. This parameter cannot be a NULL pointer.
cchMaxHeader
An integer which specifies the maximum number of characters which may be copied into the buffer, including the terminating null character. This parameter must have a value greater than zero.
lpszValue
A pointer to a string buffer that will contain the value of the first header in the current message part. This parameter may be a NULL pointer, in which case the value of the header field is ignored.
cchMaxValue
An integer which specifies the maximum number of characters which may be copied into the buffer, including the terminating null character. If the lpszValue parameter is NULL, this parameter should have a value of zero.

Return Value

If the method succeeds, the return value is non-zero. If no headers exist for the current message part, or the handle to the message is invalid, the method will return zero. To get extended error information, call GetLastError.

Remarks

Each part in a multipart message has one or more header fields. To obtain header values for the main message, rather than the message attachments, the current part number must be set to zero using the SetPart method.

The header fields from an imported message may not be returned in the same order as which they appear in the message. An application should never make an assumption about the order in which one or more header fields are defined.

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csmsgv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

EnumHeaders, GetPart, GetNextHeader, ParseHeader, SetHeader, SetPart