Scalabium Software

 

SMExport advertising

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:-)

See also
 
SMExport suite
Word Web-stream
SMReport
dBase Viewer
DBISAM Password Recovery
ABA Document Convert
ABA Database Convert
SMMsg suite
Protected Storage Viewer
SMImport suite
 
 
Contact to webmaster

 

Borland Software CodeGear Embarcadero Technologies Scalabium Delphi tips

Copyrightc 1998-2012, Scalabium Software. All rights reserved.
webmaster@scalabium.com

February 20, 2001

SMReport Autogenerated