简体   繁体   English

在VBA中获取Outlook的自动完成地址列表

[英]Get autocomplete address list of Outlook in VBA

I am trying to add all my "autocompleted addresses" to a new contact folder but I can't get those addresses. 我正在尝试将所有“自动完成的地址”添加到新的联系人文件夹中,但是我无法获取这些地址。 What I call "autocompleted addresses" are the addresses saved when you send an email to somebody and you type it again in the "To" field of a new email. 我所说的“自动完成的地址”是当您向他人发送电子邮件并在新电子邮件的“收件人”字段中再次键入时保存的地址。

I know I can get all the Global Address List by using 我知道我可以使用获取所有的全局地址列表

Set objOutlook = CreateObject("Outlook.Application")
Set myNameSpace = objOutlook.GetNamespace("MAPI")    
Set GAL = myNameSpace.AddressLists("Offline Global Address List")

But how can I get my autocompleted addresses ? 但是,如何获得自动填写的地址?

I am using Outlook 2010 and my account is an Exchange Account. 我正在使用Outlook 2010,并且我的帐户是Exchange帐户。

Thank you for your help and your time. 感谢您的帮助和时间。

EDIT 编辑

My complete code : 我完整的代码:

Set objOutlook = CreateObject("Outlook.Application")
Set myNameSpace = objOutlook.GetNamespace("MAPI")
Set folder = myNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
Set storage = folder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass)
Set propacc = storage.PropertyAccessor
Set got = propacc.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7C090102")

Problem : got is empty... 问题:得到的是空的...

Autocomplete (nickname) stream is stored in a hidden (associated) message with the message class of "IPM.Configuration.Autocomplete" in the Inbox folder. 自动完成(昵称)流存储在“收件箱”文件夹中的消息类为“ IPM.Configuration.Autocomplete”的隐藏(关联)消息中。 Its format is documented at https://msdn.microsoft.com/en-us/library/office/ff625288.aspx . 其格式记录在https://msdn.microsoft.com/zh-cn/library/office/ff625288.aspx中 You can access that message using MAPIFolder.GetStorage. 您可以使用MAPIFolder.GetStorage访问该消息。

If using Redemption is an option, it exposes nicknames through the RDOStore / RDOSession . 如果使用“ 兑换”是一个选项,它将通过RDOStore / RDOSession公开昵称。 Nicknames collection. 昵称集合。

Also note that in case of Outlook VBA you do need to create an instance of the Outlook.Application object, you already have an intrinsic Application variable pointing to that object. 还要注意,对于Outlook VBA,您确实需要创建Outlook.Application对象的实例,您已经具有指向该对象的固有Application变量。

instead of 代替

Set got = propertyAcc.GetProperty(yadayada)

Don't use Set... just 不要使用Set ...

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

This will give a zero-based array of the bytes used in the text stream. 这将给出文本流中使用的字节的从零开始的数组。
got(0) = 13 got(1) = 240 etc etc... got(0)= 13 got(1)= 240等...

From there, you can analyze each byte to get the text... but it would be very very ugly to parse it all out, when Redemption does that for you. 从那里,您可以分析每个字节来获取文本...但是,当Redemption为您完成解析时,将其全部解析出来将非常非常难看。 In fact, if you've gotten this far in the post, then you've probably sorted out that it would be a better use of time to figure out how to use Redemption than to build your own parser for this purpose. 实际上,如果您在这篇文章中走了这么远,那么您可能已经整理出,与为此目的构建自己的解析器相比,更好地利用时间来确定如何使用Redemption。

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

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