在Outlook中有Outlook聯繫人和全球地址簿,在Outlook開發中ContactItem對象指的是Outlook聯繫人。
所以當需要通過MailItem對象的Recipients得到收件人聯繫人名片時,可以使用如下方法:
Recipients recipients = mailItem.Recipients; foreach (Recipient rec in recipients) { resolved = rec.Resolve(); if (resolved) { ContactItem contactItem = rec.AddressEntry.GetContact(); String companyName = contactItem.CompanyName; // ... } }
當我們需要在ItemSend中獲取收件人ContactItem時,需要從聯繫人中指定,不要從全球地址通訊簿指定,否則rec.AddressEntry.GetContact();爲空。
MSDN中GetContact():http://msdn.microsoft.com/en-us/library/bb175073(v=office.12).aspx
Outlook開發交流 Q羣:365895439