Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

Problem accessing Outlook Addressbook

Apr 4 2003 2:55 PM
Hi, I am working on a project that needs me to retrieve outlook XP contacts and I am using C#.NET for that.I have some problem with my code. I am listing my code here Outlook.Application objOutlook = new Outlook.Application(); Outlook.NameSpace objNS = objOutlook.GetNamespace("MAPI"); objNS.Logon ("","",false,true); Outlook.MAPIFolder cContacts = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items oItems= cContacts.Items; Outlook.ContactItem oCt; int numItems; numItems = cContacts.Items.Count; for (int i=1; i <= numItems; i++) { oCt = oItems(i); Console.WriteLine(oCt.FullName); Console.WriteLine(oCt.Email1Address); } but it is throwing me an error saying that oItems denotes a variable where a method was expected for the line oCt=oItems(i) . It says that oItems cannot be used as a collection as it doesn't have Enumerator class. I tried using oItems.GetFirst() and foreach(oCt in oItems) but none of them works. can anyone please help me out with this problem.. Thanks for your time and help. Aruna

Answers (1)