Solved

How can I get outlook contact information?

Posted on 2006-11-17
4
325 Views
Last Modified: 2010-05-18
I want to get all contct list of M$ outlook~
I need Name, PhoneNumber, E-mail, ...
Exactly, My app compatible with outlook import/export outlook contact list!

0
Comment
Question by:byungho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 17965625
Couple of previous PAQ's on the same subject came up with these answers. Maybe one will help you.

1) http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20508808.html

go to torry.net and in the quick search box type in "address book" and ull get the component called twindowsaddressbook, and a sample too, for delphi 5, it works on my d6, so it should work, and then u open the sample project, and play about with it, i had to play about with it, so it would extract all the contacts from the outlook address book


2) http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21437814.html

function TForm1.GetContactsFolder(fpath : string) : OLEVariant;
var
  outlook , objns, tfolder,last : OLEVariant;
  done : boolean;
  cpath : string;
begin
  outlook := CreateOLEObject('Outlook.Application');
  objNS:= Outlook.GetNamespace('MAPI');
  tfolder := objns.GetDefaultFolder('olContacts');
  result := tfolder;
  showmessage(tfolder.name);
end;

procedure TForm1.AddFolders(cfolder : OLEVariant ; tnode : TTreeNode);
var
  cfldr,last : OLEVariant;
  done : boolean;
  ttnode,cnode : TTreeNode;
  i : integer;
begin

  for i := 1 to cfolder.items.Count do
  begin
    cnode := trvwSendTo.Items.AddChild(tnode,cfolder.items(i).fullname);
    cnode.ImageIndex:=0;
    cnode.SelectedIndex:=0;
  end;
  if cfolder.folders.Count > 0 then
  begin
    done := false;
    last := cfolder.folders.getlast;
    cfldr := cfolder.folders.getfirst;
    repeat
      if cfldr.name=last.name then
        done:=true;
      ttnode:=trvwsendto.Items.AddChild(tnode,cfldr.name);
      ttnode.ImageIndex:=1;
      ttnode.SelectedIndex:=1;
      AddFolders(cfldr,ttnode);
      cfldr:=cfolder.folders.getnext;
    until done;
  end;
end;

Procedure TForm1.PopulateTreeView;
var
  outlook, NameSpace, Contacts: OleVariant;
  tnode : TTreenode;
begin
  TrvwSendTo.items.Clear;
  outlook := CreateOLEObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');
  Contacts := NameSpace.GetDefaultFolder(olFolderContacts);
  tnode := trvwSendTo.items.addfirst(nil,'Contacts');
  tnode.ImageIndex:=1;
  tnode.SelectedIndex:=1;
  AddFolders(contacts,tnode);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  PopulateTreeView;
end;


3) http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21542066.html
0
 

Author Comment

by:byungho
ID: 17970318
thank you ..

I want to find phone numbers(bussiness, home, office..)
0
 
LVL 9

Accepted Solution

by:
bernani earned 50 total points
ID: 17971084

You can check the code I supplied here: http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21779984.html

with this code

(1 Button + 1 ListView on the Form):

implementation

{$R *.DFM}

uses comobj;

procedure TForm1.Button1Click(Sender: TObject);
const
  olFolderContacts = $0000000A;
var
  outlook, NameSpace, Contacts, Contact: OleVariant;
  i: Integer;
begin
  outlook := CreateOleObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');

  Contacts := NameSpace.GetDefaultFolder(olFolderContacts);
  for i := 1 to Contacts.Items.Count do
  begin
   Contact := Contacts.Items.Item(i);
   {now you can read any property of contact. For example, full name and email address}

   ListView1.Items.Add.Caption := Contact.FullName + ' <' + Contact.Email1Address + '>';
   end;

  Outlook := UnAssigned;
end;

With this example, all you have to do is to add a line or replace the line

   ListView1.Items.Add.Caption := Contact.FullName + ' <' + Contact.Email1Address + '>';

and change the item Contact.Email1Address by one of those:

Birthday
Business2TelephoneNumber   <--- this one for example
BusinessAddress
BusinessAddressCity
BusinessAddressCountry
BusinessAddressPostalCode
BusinessAddressPostOfficeBox
BusinessAddressState
BusinessAddressStreet
BusinessFaxNumber  
BusinessHomePage
BusinessTelephoneNumber  <--- this one for example
CompanyAndFullName
CompanyMainTelephoneNumber     <--- this one for example
CompanyName
ComputerNetworkName
Department
Email1Address
Email1AddressType
Email1DisplayName
Email2Address
Email2AddressType
Email2DisplayName
Email3Address
Email3AddressType
Email3DisplayName
FirstName
FTPSite
FullName
FullNameAndCompany
GovernmentIDNumber
Hobby
Home2TelephoneNumber
HomeAddress
HomeAddressCity
HomeAddressCountry
HomeAddressPostalCode
HomeAddressPostOfficeBox
HomeAddressState
HomeAddressStree
HomeFaxNumber
HomeTelephoneNumber          <--- this one for example
Initials
ISDNNumber
JobTitle
Language
LastName
LastNameAndFirstName
MailingAddress
MailingAddressCity
MailingAddressCountry
MailingAddressPostalCode
MailingAddressPostOfficeBox
MailingAddressState
MailingAddressStreet
MiddleName
NickName
OfficeLocation
OrganizationalIDNumber
PersonalHomePage
PrimaryTelephoneNumber
Profession
Suffix
Title
WebPage

sth like

   ListView1.Items.Add.Caption := Contact.FullName + ' <' + Contact.Business2TelephoneNumber + '>';
   ListView1.Items.Add.Caption := Contact.FullName + ' <' + Contact.BusinessTelephoneNumber  + '>';
   ListView1.Items.Add.Caption := Contact.FullName + ' <' + Contact.CompanyMainTelephoneNumber + '>';

____________________________

Hope this help.
0
 

Author Comment

by:byungho
ID: 17971500
Thank you
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question