Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a windows application that loads contacts from outlook at the start up. After I read the contacts, Sometimes Users cannot open the Outlook, Especially it will not work at all if its connected to Exchange Server. Moreover this icon will be always showing at the right side of my taskbar..

Image


C#
List<OutlookDataa> conlist = new List<OutlookDataa>();
       Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
       Microsoft.Office.Interop.Outlook.NameSpace ns = app.GetNamespace("MAPI");
       Microsoft.Office.Interop.Outlook.MAPIFolder contacts = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);

           for (int i = 1; i < contacts.Items.Count + 1; i++)
           {
               Microsoft.Office.Interop.Outlook.ContactItem contact =
               (Microsoft.Office.Interop.Outlook.ContactItem)contacts.Items[i];
               conlist.Add(new OutlookDataa(contact.FileAs, contact.BusinessTelephoneNumber.OutlookNormalize(), contact.Business2TelephoneNumber.OutlookNormalize(),
                  contact.HomeTelephoneNumber.OutlookNormalize(), contact.CompanyMainTelephoneNumber.OutlookNormalize(), contact.MobileTelephoneNumber.OutlookNormalize()));
               //#if DEBUG
               //                         Console.WriteLine(contact.FileAs);
               //#endif
           }
           FetchFinished = true;
           contacts = null;
           ns = null;
           app = null;
           GC.Collect();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900