Microsoft’s Helper Functions

Some of the Simple MAPI functions are a little cumbersome to call, to say the least. In particular, it seems a bit excessive to have to call both BMAPIReadMail and BMAPIGetReadMail simply to retrieve a list of messages. Similarly, why should we have to call both BMAPIAddress and BMAPIGetAddress to display the address book and retrieve the list of selected address entries? To help make things a little easier, Microsoft has provided a couple of helper functions in Knowledge Base article Q163216, Updated Mapivb32.bas for Simple MAPI on 32-Bit Platforms. (Search for this article on the Microsoft Developer Network [MSDN] web site at http://msdn.microsoft.com.) The article provides MAPIReadMail, which wraps BMAPIReadMail and BMAPIGetReadMail, and MAPIAddress, which wraps BMAPIAddress and BMAPIGetAddress.

Here is the syntax for the MAPIReadMail function:

Function MAPIReadMail(Session As Long, UIParam AsLong, MessageID As String, Flags 
As Long, Reserved As Long, Message As MAPIMessage, Orig As MapiRecip,RecipsOut( ) 
As MapiRecip, FilesOut( ) As MapiFile) As Long

The parameters are:

Session

The session handle that was obtained in a previous call to MAPILogon. Alternatively, pass to cause MAPI to log on the user and create a session that exists only for the duration of the call. If necessary, a dialog box is displayed to request further logon information from the user.

UIParam

The handle of the window that is to be considered the parent of any dialog boxes ...

Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.