[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can I get outlook contact information?

Posted on 2006-11-17
4
Medium Priority
?
345 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 150 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

656 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