C#Windows应用程序中的Outlook自动化会产生问题 [英] Outlook Automation in C# Windows Application makes Problems

查看:39
本文介绍了C#Windows应用程序中的Outlook自动化会产生问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows应用程序,可以在启动时从outlook加载联系人。读取联系人后,有时用户无法打开Outlook,特别是如果它连接到Exchange Server,它将无法正常工作。此外,此图标将始终显示在我的任务栏的右侧..



图片





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


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();

推荐答案

这篇关于C#Windows应用程序中的Outlook自动化会产生问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆