問題描述
Outlook 2010 自動完成流(緩存的聯繫人) (Outlook 2010 autocomplete stream ( cached contacts))
I'm currently trying to develop an outlook plugin. As to implement a non functional requirenment I need to access outlook cached contacts which are stored in .nk2 file. I refered to this post but couldn't figure out how to do it.
Edited (Answer):
Microsoft.Office.Interop.Outlook.Application oApp = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = oApp.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox);
StorageItem storage = inboxFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass);
//IPM.Configuration.Autocomplete
PropertyAccessor propertyAcc = storage.PropertyAccessor;
byte[] got = propertyAcc.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7C090102");
Currently I'm stuck in accessing byte array, When I accesing the array the values are different than how it's mentioned in this post
‑‑‑‑‑
參考解法
方法 1:
Microsoft.Office.Interop.Outlook.Application oApp = Globals.ThisAddIn.Application;
Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = oApp.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox);
StorageItem storage = inboxFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass);
PropertyAccessor propertyAcc = storage.PropertyAccessor;
byte[] got = propertyAcc.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7C090102");
use the description here to access the fields in the byte[]
. I completed the code it's working correctly. You just have to loop through each byte and check for data types when accessing .
方法 2:
Edit:
Can you use a object instead of a byte array (if that doesn't work, hover your mouse over the GetProperty
during debugging and see what return type it expects). eg:
Dim objPropAcc As Outlook.PropertyAccessor
Dim result As Object
objPropAcc = BindingStorageItem.PropertyAccessor
result = objPropAcc.GetProperty("http://schemas.microsoft.com/mapi/id/{00062040‑0000‑0000‑C000‑000000000046}/8A48001E").ToString();
Ref: how to get a sharepoint calendar url from outlook?
Old:
Here is a Microsoft KB article How to import .nk2 files into Outlook 2010
Outlook 2007 and 2010 interact with the nickname cache, also known as the “autocomplete stream.” The autocomplete stream is where Outlook persists the autocomplete list, which is the list of names that displays in the To, Cc, and Bcc edit boxes while a user is composing an email. This topic here describes how Outlook 2007 and Outlook 2010 interact with the autocomplete stream and also discusses the binary format of the file and the recommended ways for interacting with the autocomplete stream.
Also have a look at some of the sample's over here: http://ol2010mapisamples.codeplex.com/, I think this codeplex project is run by the MAPI expert Stephen Griffin.
(by Proceso、Proceso、Jeremy Thompson)