|
-
November 26th, 2004, 06:30 PM
#1
Access outlook contacts from C#
Hi
I want to get phonenumbers from my outlook contacts. Anyone have any idea how to do this in C#? If you have any tips at all, plz post... I am really stuck here.
Thanks in advance!
-
November 27th, 2004, 10:05 AM
#2
Re: Access outlook contacts from C#
Here is a sample. Create a new Windows Forms project. Add a list box and a button to the form. From menubar select Project|Add Reference. Select the COM tab and add a reference to Microsoft Outlook 10.0 Object Library.
Now add the following code
Code:
private void button2_Click(object sender, System.EventArgs e) {
Outlook._Application outlook = new Outlook.ApplicationClass();
Outlook.NameSpace ns = outlook.GetNamespace("MAPI");
Outlook.MAPIFolder cf = ns.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Items ctcItems = cf.Items;
Outlook.ContactItem ctc;
for(int j = 1; j < (ctcItems.Count + 1); j++) {
ctc = (Outlook.ContactItem) ctcItems.Item(j);
list1.Items.Add(ctc.FullName.ToString());
}
}
This will add the full name from each contact item to the list box.
Last edited by Sahir; November 27th, 2004 at 10:11 AM.
-
November 27th, 2004, 10:22 AM
#3
Re: Access outlook contacts from C#
Thanks a lot!
-
October 20th, 2005, 06:50 AM
#4
Re: Access outlook contacts from C#
Hi ,
I tried that coding u have poested here.But there is an error.
ctc = (Outlook.ContactItem) ctcItems.Items(j);
There is no Items method in ctcItems.What shall I do?
***BTW I was searching thw net to find "How to access outlook contacts from C# n this answer given by u is the one n only in the net.
Regards
-
October 21st, 2005, 03:09 AM
#5
Re: Access outlook contacts from C#
This should work
Code:
ctc = (Outlook.ContactItem) ctcItems[j]
And be sure you working with rightversion of Microsoft Outlook 10.0 Object Library.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|