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:

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

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
 
ABA Spreadsheet Convert
Database Information Manager
SMImport suite
Fast Document Viewer
Metafile Convert
SMMsg suite
SMReport
dBase Viewer
SMDBGrid
Protected Storage Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2025, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising