TransportRecv

The TransportRecv function gets a specific message from the mail server. The number of MailMsg messages that can be retrieved is between 1 and the number returned by TransportCount.

Syntax

BOOL TransportRecv(HANDLE hService, WORD wMessageId, short sNumLines, MailMsg *MsgPtr, lpMailAttArray *lplpMaa);

At a Glance

Header file: Smtp.h
Platforms: H/PC
Windows CE versions: 1.0 and later

Parameters

hService
Handle to a SERVICE structure.
wMessageId
Identifier of the message for this session. If this value is zero, the unique message identifier stored in the szSvcId member of the MailMsg structure is used. For more information, see Implementing a Sample Transport Service.
sNumLines
Number of lines to receive. For the sample service, sNumLines is assigned value indicating the number of lines to be read.

If only message information is to be returned, sNumLines is set to one of the following flags:

TRANSPORT_MSG_EXIST
Used to check for the existence of a message, without allocating any memory. Neither the message header nor the message body is read.
TRANSPORT_ALL_LINES
Returns the unique identifier stored in the szSvcId member of the MailMsg structure as determined from wSessionId.
TRANSPORT_HEADERS
Parses the message header and places the information in MsgPtr, also without allocating any memory. The message body is not read.
MsgPtr
A MailMsg structure that contains the message to be read.
lplpMaa
For Windows CE version 1.0, this parameter is reserved must be set to NULL. For version 2.0, it is a pointer to lpMailAttArray which itself is a pointer to a MailAttArray structure.

Return Values

Returns TRUE if successful or FALSE otherwise. To get extended error information, call TransportError or TransportErrorMsg.

Remarks

The TransportRecv function must be implemented by the transport service provider in a DLL registered as a mail service. The Inbox application can load this DLL and call this function.

For the sample transport service, TransportRecv receives a message via hService and copies the message (or message information) into the MsgPtr structure. If the calling application wishes only to check for the existence of the message, or just obtain header information, the calling application sets sNumLines to TRANSPORT_MSG_EXIST.

A typical TransportRecv routine opens the file containing the message (specified in hService), allocates heap space, parses the header, and fills the various MsgPtr fields with the appropriate information. After assigning pointers to the heap, header, and body fields of MsgPtr, the sample TransportRecv frees the memory allocated to MsgPtr, but leaves the heap it created intact. The heap must be destroyed by using TransportFreeMsg.

If the lplpMaa parameter returns a valid pointer and the transport determines that attachments are to be added to the message, then a MailAttArray structure should be allocated from the message heap and initialized with appropriate attachment information.

See Also

TransportFreeMsg