Connie McBride 0 Posted 9 hours ago I'm trying to figure out how to retrieve the contacts from outlook from a specific list. for example, I have been able to get the address lists: and now I want to select one of those items (offline global address list, for instance) and get all the contacts/emails from that specific list. I am having no luck working that part out. any help? Share this post Link to post
Pat Foley 54 Posted 8 hours ago One way is save as .pst file or .csv file inside of Outlook. Second way is use VBA to learn the names of methods that Outlook uses to save lists in different formats. Share this post Link to post
Die Holländer 85 Posted 1 hour ago (edited) I found some old code to retrieve the list of a group, like "Global Address List" The code here is based on to put the addresses in a TreeView. I checked the code and it is still running OK but I noticed that I don't see the e-mail addresses anymore but instead it reports a string like: "/o=ExchangeLabs/ou=....." Maybe this is because of the exchange server configuration in my environment. see: how-to-get-email-address-from-o-exchangelabs-ou-exchange-administrative-group You have to play with it to see if you get the proper info you want. Maybe you can post the final answer here if you find the proper addresses.. Note that the code has a filter to only show two groups: If (CurGroupName='All Groups') or (CurGroupName='Global Address List') Then... //Uses Outlook2000; Procedure TMailTrans.CreateGALTreeForSendMailItem(aTreeView : TTreeView); Var pProp : PSPropValue; MP : IMAPIProp; strAddress : String; i, j, Check: Integer; myAddressList: AddressList; myAddressLists: AddressLists; myAddressEntries: AddressEntries; myAddressEntry: AddressEntry; CurNode, ChildNode, DetailNode :TTreeNode; CurGroupName : String; begin If NmSpace=NIL Then Begin OutlookApplication1.Connect; NmSpace:=OutlookApplication1.GetNamespace('MAPI'); NmSpace.Logon('', '', False, False); End; myAddressLists := IUnknown(NmSpace.AddressLists) as AddressLists; aTreeView.Items.BeginUpdate; aTreeView.Items.Clear; for i := 1 to myAddressLists.Count do begin CurGroupName:=myAddressLists.Item(i).Name; If (CurGroupName='All Groups') or (CurGroupName='Global Address List') Then Begin CurNode:=aTreeView.Items.Add(Nil,myAddressLists.Item(i).Name); CurNode.ImageIndex:=2; CurNode.SelectedIndex:=2; myAddressList := myAddressLists.Item(i); if Assigned(myAddressList.AddressEntries) then Begin myAddressEntries := myAddressList.AddressEntries; for j := 1 to myAddressEntries.Count do begin strAddress:='Unknown'; myAddressEntry := myAddressEntries.Item(j); if Assigned(myAddressEntry) then Begin if myAddressEntry.MAPIOBJECT<>NIL then Begin if Assigned(myAddressEntry.MAPIOBJECT) then Begin { Check:=IUnknown(myAddressEntry.MAPIOBJECT).QueryInterface(IMailUser,MP); If Check=0 then MP:=IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser else MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList; if S_OK = HrGetOneProp(MP, $39FE001E, pProp) then begin strAddress:=String(pProp.Value.lpszA); MAPIFreeBuffer(pProp); end; // else strAddress:=myAddressEntry.Address; } strAddress:=myAddressEntry.Address; ChildNode:=aTreeView.Items.AddChild( CurNode, myAddressEntry.Name); ChildNode.ImageIndex:=7; ChildNode.SelectedIndex:=7; DetailNode:=aTreeView.Items.AddChild( ChildNode, strAddress); DetailNode.ImageIndex:=6; DetailNode.SelectedIndex:=6; End; End; { DetailNode:=aTreeView.Items.AddChild( ChildNode, myAddressEntry.Address); DetailNode.ImageIndex:=6; DetailNode.SelectedIndex:=6; } End; End; End; end; //Application.Processmessages; end; aTreeView.Items.EndUpdate; end; Edited 1 hour ago by Die Holländer Share this post Link to post