Link to home
Start Free TrialLog in
Avatar of zvi_kleiner
zvi_kleiner

asked on

need help!!! how to edit the outlook address book using MAPI

Can some 1 tell me how to add/extrect data from the contacts list in outlook using delphi MAPI
 I managed to make a valid Session by using the function MAPILogon

MAPILogon(0,'','',0,0,@hSession);

Where hSession is defined as ULONG, the function returnd SUCCESS_SUCCESS.
next I used
MapiAddress(hSession,0,'',0,'',0,recips,MAPI_LOGON_UI,0,0,newrecips);

it displayed a standard address-list dialog box
The problem is what to do now, ho can I get all the address book list to a DBGrid
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Hi zvi_kleiner,

in case you could use a sample

http://www.econos.de/software/borland/email2/

HTH:O)Bruintje
Avatar of zvi_kleiner
zvi_kleiner

ASKER

Edited text of question.
Bruintje thanks for the samples.
I was wandering if I can get more then
a Name an Email from the address Book.
I need the whole DataBase ?????!!!!!


Hello,

Yes you can get more.
You could use code from this procedure.
And use objAddresses.AddressEntries.Item(i).Property to get more from the 'whole database'.

Offcourse you need to import the outlook library for this. You can create an Outlook instance with:
FOutlook := CreateOleObject('Outlook.Application');

FOutlook is an OleVariant.


procedure TOutlookAdres.OleGetNamenEnEmail(var stringlist:TStringList);
{***********************************************************
pre: outlook is running
discription: get name+email, put them in TStringList
inputs: var TStringList
returns: var TStringList
***********************************************************}
var
objNS, objAddressLists, objAddresses: Olevariant;
i, k: integer;
s : string;
begin
FOutlook := GetActiveOleObject('Outlook.Application');
objNS:= FOutlook.GetNamespace('MAPI');
objAddressLists:= objNS.AddressLists;
objAddresses:= objAddressLists.Item(1);
k:= objAddresses.AddressEntries.Count;
  for i:=1 to k do
      begin
      s := (objAddresses.AddressEntries.Item(i).Name+', Email: '+objAddresses.AddressEntries.Item(i).Address);
      stringlist.add(s);
      end;
end;


Greetings,
Floris.
Thenk's Floris I will accept ur comment as the answer. I just need to know what
are all the property's.
besides Name & Address property
ASKER CERTIFIED SOLUTION
Avatar of florisb
florisb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial