RETURNS LOGICAL
( INPUT-OUTPUT iop-Email AS CHARACTER ) :
/*------------------------------------------------------------------------------
Purpose: Passed in an email address, fires up the address book to allow the
user to select an email address(es). Returns updated list of addressed
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE h-Session AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE h-Recipients AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE h-Recipient AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE h-Message AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE h-DefaultRecipients AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE h-DefaultRecipient AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE v-Selected AS LOGICAL NO-UNDO.
DEFINE VARIABLE v-Count AS INTEGER NO-UNDO.
DEFINE VARIABLE v-Email AS CHARACTER NO-UNDO.
/* Get a session */
assign h-Session = f-MAPIGetSession().
/* Handle failure */
IF NOT VALID-HANDLE(h-Session) THEN
RETURN FALSE.
IF iop-Email <> "" THEN
DO:
/* If we've been passed in email addresses, we need to create a recipients
collection to use as the default value for the addressbook call */
/* Create our dummy message */
h-Message = h-Session:outbox:messages:add.
h-DefaultRecipients = h-Message:Recipients.
/* Loop through the addresses */
DO v-Count = 1 TO NUM-ENTRIES(iop-Email,";"):
/* Create a recipient */
h-DefaultRecipient = h-DefaultRecipients:Add.
h-DefaultRecipient:name = ENTRY(v-Count,iop-Email,";").
h-DefaultRecipient:Type = 1. /* To */
END.
h-DefaultRecipients:resolve().
/* The address book returns a recipients collection */
h-Recipients = h-Session:addressbook(h-DefaultRecipients) NO-ERROR.
END.
ELSE
/* Otherwise call the addressbook without any defaults */
h-Recipients = h-Session:addressbook() NO-ERROR.
/* If the user cancelled */
IF NOT VALID-HANDLE(h-Recipients) THEN
ASSIGN v-Selected = FALSE.
ELSE
DO:
ASSIGN v-Selected = TRUE.
/* The user may have selected a number of addresses */
DO v-Count = 1 TO h-Recipients:COUNT:
/* Get the individual recipient */
ASSIGN h-Recipient = h-Recipients:ITEM(v-Count).
/* and take a note of the address */
ASSIGN v-Email = v-Email +
( IF v-Email = "" THEN ""
ELSE "; " ) +
h-Recipient:NAME.
END.
END.
/* Delete the dummy message */
h-Message:DELETE NO-ERROR.
/* Logoff */
h-Session:logoff.
/* Tidy up */
RELEASE OBJECT h-DefaultRecipient NO-ERROR.
RELEASE OBJECT h-DefaultRecipients NO-ERROR.
RELEASE OBJECT h-Message NO-ERROR.
RELEASE OBJECT h-Recipient NO-ERROR.
RELEASE OBJECT h-Recipients NO-ERROR.
RELEASE OBJECT h-Session NO-ERROR.
ASSIGN iop-Email = v-Email.
RETURN v-Selected.
END FUNCTION.