简体   繁体   English

使用C#编辑Outlook联系人

[英]Editing outlook contacts using C#

I am developing a desktop application using C#, and I do not know how to edit a contact info in outlook, I Google-d it but no use. 我正在使用C#开发桌面应用程序,但我不知道如何在Outlook中编辑联系人信息,我在Google上进行了搜索,但没有用。

I know how to retrieve and add contacts to outlook, what I am asking about is updating contacts. 我知道如何检索联系人并将其添加到Outlook,我要问的是更新联系人。

any suggestions? 有什么建议么?

The solution is quite easy, though I did not find it using google. 该解决方案非常简单,尽管我没有使用google找到它。

  1. retrieve the outlook contact. 检索前景联系人。

      Outlook.Items ctcItems = cf.Items; Outlook.Items items = ctcItems; Outlook.ContactItem ctc = (Outlook.ContactItem)items[index]; 

cf in the code above is the Outlook.MAPIFolder . 上面代码中的cf是Outlook.MAPIFolder

  1. update the Outlook.ContactItem . 更新Outlook.ContactItem

     ctc.FullName = "Laurel"; 

    . . . . .

  2. save Outlook.ContactItem . 保存Outlook.ContactItem

     ctc.Save(); 

Another solution. 另一个解决方案。

Microsoft.Office.Interop.Outlook.Application outlookApp = new 
Microsoft.Office.Interop.Outlook.Application();

MAPIFolder Folder_Contacts = (MAPIFolder)
outlookApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);       

var filter = String.Format("[FullName] = '{0}'", "Jose da Silva" );

ContactItem contact = (ContactItem)Folder_Contacts.Items.Find(filter);

if (contact != null)
{
    contact.FullName = "Joao da Silva";
    contact.Email1Address = "joao@silva.com.br";
    contact.Save();
}

Download and install VSTO , then add a reference to Microsoft.Office.Interop.Outlook to your project. 下载并安装VSTO ,然后将对 Microsoft.Office.Interop.Outlook的引用添加到您的项目中。 This will give you access to the Outlook object model. 这将使您可以访问Outlook对象模型。

http://geekswithblogs.net/timh/archive/2006/05/26/79720.aspx http://geekswithblogs.net/timh/archive/2006/05/26/79720.aspx

I might try to above. 我可能会尝试以上。 It looks like first you reference the Outlook COM object , and then create a Microsoft.Office.Interop.Outlook.Application from which you should be able to edit outlook objects. 看起来像先引用Outlook COM对象 ,然后创建一个Microsoft.Office.Interop.Outlook.Application ,您应该可以从中编辑Outlook对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM