CPopClient::GetMessageSender Method  
 
INT GetMessageSender(
  UINT nMessageId,  
  LPTSTR lpszAddress,  
  INT nMaxLength  
);
INT GetMessageSender(
  UINT nMessageId,  
  CString& strAddress  
);

The GetMessageSender method returns the sender's address for the specified message.

Parameters

nMessageId
Number of message to retrieve header value from. This value must be greater than zero. The first message in the mailbox is message number one.
lpszAddress
Pointer to a string buffer that will contain the address of the message sender. This argument may also be a CString object which will contain the address when the method returns.
nMaxLength
The maximum number of characters that may be copied into the buffer, including the terminating null character.

Return Value

If the method succeeds, the method returns the length of the address. If the sender cannot be determined, the method will return a value of zero. If the method fails, the return value is POP_ERROR. To get extended error information, call GetLastError.

Remarks

The GetMessageSender method returns the email address of the user who sent the specified message. This allows an application to be able to easily determine the sender, without downloading the entire header block or contents of the message.

This method uses the XSENDER command, which is an extension to the POP3 protocol, to determine the address of the authenticated sender of the message. If the command is not supported, or the server was unable to authenticate the sender, the method will use the XTND XLST command to obtain the value of the "From" header field. If this command is not supported by the server, the method will attempt to retrieve the entire message header and return the value for the specified header field. This enables an application to use this method even if the server does not support command extensions.

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: cspopv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

GetHeaderValue, GetMessageHeaders, GetMessageId, GetMessageUid