O'Reilly logo

CDO & MAPI Programming with Visual Basic: by Dave Grundgeiger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required