代码之家  ›  专栏  ›  技术社区  ›  benbants

Outlook-如何访问自动完成的地址列表

  •  0
  • benbants  · 技术社区  · 7 年前

    我希望能够访问自动完成的地址列表,当键入电子邮件中的收件人、抄送或密件抄送行时显示。我希望能够像在Outlook中访问其他地址列表一样提取这些数据。

    这就是我目前提取电子邮件地址和其他地址列表的方式。

    foreach (Outlook.AddressEntry item in addressList.AddressEntries)
        {
            using (item.ComDisposable())
               {
                   switch (item.AddressEntryUserType)
                       {
                           case Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry:
                           case Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry:
                               var exUser = item.GetExchangeUser();
                               Debug.WriteLine(exUser.PrimarySmtpAddress, "_GetOutlookContacts");
                               yield return new EGContact(exUser.Name, exUser.PrimarySmtpAddress, item.ID);
                               break;
    
                           case Outlook.OlAddressEntryUserType.olOutlookContactAddressEntry:
                                var contact = item.GetContact();
                                yield return new EGContact(contact.FullName, contact.Email1Address, item.ID);
                                break;
    
                           case Outlook.OlAddressEntryUserType.olExchangeDistributionListAddressEntry:
                           break;
    
                           default:
                           break;
    
                      }
              }
        }
    
    2 回复  |  直到 7 年前
        1
  •  2
  •   Dmitry Streblechenko    3 年前

    自动完成流作为隐藏(关联)消息存储在收件箱文件夹中,消息类为“IPM.Configuration.Autocomplete”。您可以在中看到数据 OutlookSpy

    您可以使用Outlook对象模型打开该邮件( MAPIFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass ),使用读取属性 PropertyAccessor.GetProperty ,然后对其进行解析。请注意,无法使用PropertyAccessor打开大型自动完成流。

    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
    
        2
  •  1
  •   Eugene Astafiev    7 年前

    Clearing AutoComplete and other Recipient Caches 了解更多信息。

    Recipients 用于访问输入到“收件人”、“抄送”或“密件抄送”字段的数据的集合(请参阅MailItem类的相应属性)。