[英]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.