简体   繁体   English

如何从 Outlook 中读取缓存条目,然后将它们保存为通讯录中的联系人?

[英]How can I read in the cache entries from outlook and then save them as contacts in my address book?

I am currently programming an Outlook Add-in with C# in Visual Studio.我目前正在 Visual Studio 中使用 C# 编写 Outlook 加载项。 Now I would like to read in existing entries of the cache in order to automatically save the contacts contained therein as an entry in my address book.现在我想读取缓存的现有条目,以便自动将其中包含的联系人保存为我的地址簿中的条目。 Can anyone help me further on how I can access the cache and then implement my function?谁能帮助我进一步了解如何访问缓存然后实现我的功能?

So far I already did following steps:到目前为止,我已经做了以下步骤:

public partial class ThisAddIn
{
...
private Outlook.Application OutlookApplication;
private MAPIFolder inboxFolder;
...
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
...
 inboxFolder = Application.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox);
...
}

private void saveContact()
{
StorageItem storage = inboxFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByEntryID);
PropertyAccessor propertyAcc = storage.PropertyAccessor;
byte[] got = propertyAcc.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7C090102");
}

I am currently calling the method for testing when opening an inspector.我目前正在调用打开检查器时的测试方法。

So far I get the following error message: System.Runtime.InteropServices.COMException: "The StorageItem item cannot be created in this folder. Either the folder is read-only, or storage items are not allowed in this folder. "到目前为止,我收到以下错误消息:System.Runtime.InteropServices.COMException:“无法在此文件夹中创建 StorageItem 项。该文件夹是只读的,或者此文件夹中不允许存储项。”

Can somebody help me fix my error?有人可以帮我解决我的错误吗?

The autocomplete (nickname) cache stream is stored in a hidden message with the message class of IPM.Configuration.Autocomplete in the Inbox folder (see the associated content of the folder).自动完成(昵称)缓存流存储在收件箱文件夹中消息类别为IPM.Configuration.Autocomplete的隐藏消息中(请参阅文件夹的相关内容)。 The format is documented, see Nickname cache .该格式已记录在案,请参阅昵称缓存 You can access that message using MAPIFolder.GetStorage and then you can get the stream itself:您可以使用MAPIFolder.GetStorage访问该消息,然后您可以获取流本身:

Set propAcc = storage.PropertyAccessor
Set got = propertyAcc.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7C090102")

You may find the Get autocomplete address list of Outlook in VBA thread helpful.您可能会发现在 VBA 线程中获取 Outlook 的自动完成地址列表很有帮助。

Autocomplete stream is stored as a hidden (associated) message with the message class of "IPM.Configuration.Autocomplete" in the Inbox folder.自动完成流存储为收件箱文件夹中消息类别为"IPM.Configuration.Autocomplete"的隐藏(关联)消息。 You can see the data in OutlookSpy (I am its author): go to the Inbox folder, click IMAPIFolder button on the OutlookSpy ribbon, go to the "Associated Contents" tab, locate a message with PR_MESSAGE_CLASS == "IPM.Configuration.Autocomplete", select the PR_ROAMING_BINARYSTREAM property to see its contents.您可以在OutlookSpy中看到数据(我是它的作者):转到收件箱文件夹,单击 OutlookSpy 功能区上的 IMAPIFolder 按钮,转到“关联内容”选项卡,找到一条带有 PR_MESSAGE_CLASS ==“IPM.Configuration.Autocomplete”的消息",选择PR_ROAMING_BINARYSTREAM属性以查看其内容。

You can open that message using the Outlook Object Model ( MAPIFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass ), read the property using PropertyAccessor.GetProperty , then parse it. Note that large (>30kB) autocomplete streams cannot be opened using PropertyAccessor .您可以使用 Outlook 对象模型 ( MAPIFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass ) 打开该消息,使用PropertyAccessor.GetProperty读取属性,然后对其进行解析。请注意,大型 (>30kB) 自动完成流不能使用PropertyAccessor打开。

If using Redemption an option (I am also its author), it exposes autocomplete as the RDONicknames collection:如果使用Redemption选项(我也是它的作者),它会将自动完成功能公开为RDOnicknames集合:

 set Session = CreateObject("Redemption.RDOSession")
 Session.MAPIOBJECT = Application.Session.MAPIOBJECT
 set Nicknames = Session.GetNicknames
 for each NickName in NickNames
     Debug.Print NickName.Name & " - " & NickName.SmtpAddress
 next

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

相关问题 如何在通讯录中保存联系人并列出联系人? - How to save contacts in an address book and list them? 无法从Outlook 2010中的通讯簿中删除联系人 - Can't remove contacts from an address book in Outlook 2010 如何以编程方式访问Outlook中的共享邮箱的联系人通讯簿 - How to access shared mailbox's Contacts Address Book in Outlook programmatically 如何从全球通讯簿中获取Outlook日历? - How to get Outlook calendars from global address book? 无法在Outlook 2010中删除通讯簿 - Can't remove address book in Outlook 2010 如何将我的应用程序设置保存到文本文件并在加载时重新读取? - How can i save settings of my app to a text file and read them back on load? 来自Outlook通讯录的自动完成源 - autocomplete source from Outlook address book 如何从 outlook email 帐户获取数据,例如电子邮件、联系人和日历事件,并将其显示在列表中? - How can I get the data from an outlook email account, such as emails, contacts, and calendar events, and show it inside a list? 如何使用c#从外部应用程序访问特定文件夹中的Outlook 2013联系人? - How can I access Outlook 2013 contacts in a certain folder from an external app using c#? 如何使用VSTO检索Outlook联系人列表? - How can I retrieve list of outlook contacts using VSTO?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM