MAPIQueryRecipientList

Syntax

MAPIQueryRecipientList(Recipients, RecipName$, Address$)

Remarks

Retrieves information about recipients in a recipient list. On the first call to MAPIQueryRecipientList, Recipients must be a handle
to a recipient list of the type returned by MAPIAddress. The MAPIQueryRecipientList function returns –1 to indicate that there are no
more recipients. Otherwise, it returns the recipient class of the recipient.

Argument

Explanation

Recipients

A handle to a recipient list on the first call to MAPIQueryRecipientList. Use 0 (zero) for succeeding calls.

RecipName$

The friendly name of the recipient as displayed by the messaging system.

Address$

Provider-specific message delivery data. This field can be used by the message system to identify recipients who are not in an address list (custom recipients).


The following table lists the possible return values of the MAPIQueryRecipientList function and their meanings.

Value

Name

Meaning

0

MAPI_ORIG

The recipient is the originator of the message.

1

MAPI_TO

The recipient is a To recipient of the message.

2

MAPI_CC

The recipient is a carbon-copy (CC) recipient of the message.

3

MAPI_BCC

The recipient is a blind carbon-copy (BCC) recipient of the message.

–1

Either the recipient list contains no recipients or all recipients have been queried.


Example

The following example displays the Mail Address Book, which returns a handle to a recipient list. The example then prompts the user to resolve any unresolved names in the list. Finally, all resolved names are added to a new message.


Sub MAIN
MAPI_LOGON_UI = 1
MAPI_DIALOG = 8
Session = MAPILogon(0, "", "", MAPI_LOGON_UI, 0)
RecipList = MAPIAddress(Session, 0, "", 4, "", 0, 0)
If RecipList >= 0 Then
    'Query the first recipient
    RecipClass = 0
    RecipName$ = ""
    Address$ = ""
    RecipClass = MAPIQueryRecipientList(RecipList, RecipName$, Address$)
    While RecipClass >= 0
        'Process the recipient
        If Address$ <> "" Then
            result = MAPISetRecipient(RecipClass, RecipName$, Address$)
        Else
            ResolveList = MAPIResolveName(Session, 0, RecipName$, \
              Address$, MAPI_DIALOG, 0)
            If ResolveList >= 0 Then
                result = MAPIQueryRecipientListElement(ResolveList, 0, \
                  RecipName$, Address$)
                result = MAPISetRecipient(RecipClass, RecipName$, \
                  Address$)
            Else
                result = MAPISetRecipient(RecipClass, RecipName$, "")
            End If
        End If
        'Query the next recipient
        RecipClass = 0
        RecipName$ = ""
        Address$ = ""
        RecipClass = MAPIQueryRecipientList(0, RecipName$, Address$)
    Wend
    'Display the Send Note dialog
    result = MAPISendMail(Session, 0, "", "", MAPI_DIALOG, 0)
End If
result = MAPILogoff(Session, 0, 0, 0)
End Sub