Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips

#117: How can I select a recipient from addressbook?

Today I want to post a tip about copying of recipients from default addressbook. For example, user must select a list of recipients and you'll process this list in own code (to send a message to these recipients or just import them into own database).

For this task you can use the MAPIAddress procedure from MAPI. This procedure requires a handle of current session (which you'll receive from MAPILogOn procedure), custom caption of dialog, structure for recepient attributes and variable where you'll receive a number of selected recipients.

If MSPIAddress returns SUCCESS_SUCCESS, this mean that user closed a dialog and selected some recipients. After that you must navigater by recipient structure (which you defined as parameter) and process the each recipient.

For example:

  lpRecip: TMapiRecipDesc;
  intRecips: ULONG;
  lpRecips: PMapiRecipDesc;
  i: Integer;
  if (MAPIAddress(intMAPISession, 0, 'Select the recipients', 4, '', 0, lpRecip, 0, 0, @intRecips, lpRecips) = SUCCESS_SUCCESS) then
    for i := 0 to intRecips-1 do
      yourListBox.Items.Add(PMapiRecipDesc(PChar(lpRecips) + i*SizeOf(TMapiRecipDesc))^.lpszAddress);

where intMAPISession is an integer varaiable wchich store the handle of current MAPI session. If you don't use the MapiLogOn which return this handle, just place a zero value there:
intMAPISession := 0;

I hope that this tip will help you and save some time. At least when I wrote (in October 2000) this code for own GroupMail, I spent a lot of time for correct work without errors:-)

Published: February 20, 2001

See also
Paradox Viewer
Database Information Manager
Paradox to Text converter
SMExport suite
ExcelFile Viewer
Paradox to MS Access converter
dBase Viewer
Paradox ActiveX

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2023, Scalabium Software. All rights reserved.

SMExport/SMImport suites