|
INT GetHeader( |
|
INT nMessagePart, |
|
|
LPCTSTR lpszHeader, |
|
|
LPTSTR lpszValue, |
|
|
INT nMaxValue |
|
); |
INT GetHeader( |
|
LPCTSTR lpszHeader, |
|
|
LPTSTR lpszValue, |
|
|
INT nMaxValue |
|
); |
INT GetHeader( |
|
INT nMessagePart, |
|
|
LPCTSTR lpszHeader, |
|
|
CString& strValue |
|
); |
INT GetHeader( |
|
LPCTSTR lpszHeader, |
|
|
CString& lpszValue |
|
); |
The GetHeader copies the value of the specified header into
a string buffer.
Parameters
- nMessagePart
- An integer value which specifies which part of the message to
return the header value from. A value of zero returns a header
value from the main message header, while a value greater than zero
returns the header value from that specific part of a multipart
message. A value of -1 specifies that the header value should be
returned from the current message part. If this argument is
omitted, the value will be returned from the current message
part.
- lpszHeader
- A pointer to a string which specifies the message header.
- lpszValue
- A pointer to a string buffer which will contain the value of
the specified header when the method returns. If this parameter is
NULL, the method will return the length of the header value without
copying the data. This is useful for determining the length of a
header value so that a string buffer can be allocated and passed to
a subsequent call to the method. In alternate forms of this method,
a CString object may be specified which will contain the
header field value when the method returns.
- nMaxValue
- An integer value which specifies the maximum number of
characters that can be copied to the string buffer, including the
terminating null character. If the lpszValue parameter is NULL,
this value should be zero.
Return Value
If the method succeeds, the return value is the number of bytes
copied into the string buffer, not including the terminating null
byte. If the lpszValue parameter is NULL, the return value is
the length of the header value. If the header field does not exist, a
value of zero is returned. If an invalid pointer or message part is
specified, a value of MIME_ERROR is returned. To get extended error
information, call GetLastError.
Example
CMailMessage *pMessage = new CMailMessage();
CString strSubject;
// Compose a test message
pMessage->ComposeMessage(_T("Bob Jones <bob@example.com>"),
_T("Tom Smith <tom@example.com>"),
NULL,
_T("This is a test message"),
_T("This is a test, this is only a test."));
// Change the subject of the message
if (pMessage->GetHeader(0, _T("Subject"), strSubject))
{
strSubject = _T("Re: ") + strSubject;
pMessage->SetHeader(0, _T("Subject"), strSubject);
}
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,
GetFirstHeader,
GetHeader,
GetPart,
GetNextHeader,
ParseHeader,
SetHeader,
SetPart
|
|