Showing the Address Book
writing an application that allows the user to enter recipients for
an outgoing message, it’s convenient for the user to have a way
to display the address book and to select recipients directly from
it. In Simple MAPI, this is done using a combination of two
BMAPIAddress displays the address book and
records the user’s selections (internally), returning a handle
to the selections through an out parameter.
BMAPIGetAddress accepts the handle as input and
returns (again through an out parameter) an array of
MapiRecip records representing the address entries
selected from the address book. This array can then be passed to the
MAPISendMail function. Example 3-5 demonstrates this process. Figure 3-4 shows the address book dialog box displayed by
the MAPI system when
Example 3-5. Showing the Address Book
' Assume that a MAPI session has already been established, and that ' nMAPISession holds the session handle. Dim nRetVal As Long Dim MyMessage As MAPIMessage Dim MyRecips( ) As MapiRecip Dim MyFiles( ) As MapiFile Dim nInfo As Long Dim nRecipients As Long ' Set the subject and body text of the message. MyMessage.Subject = "Test message from Simple MAPI." MyMessage.NoteText = "This is the body text of the message." ' Show the address book to allow the user to select recipients. nRetVal = BMAPIAddress(nInfo, nMAPISession, 0, "Select Names", 4, "", _ nRecipients, MyRecips, 0, 0) If ...