到目前为止,这是我的代码:
import win32com.client
o = win32com.client.gencache.EnsureDispatch("Outlook.Application")
ns = o.GetNamespace("MAPI")
adrLi = ns.AddressLists.Item("Global Address List")
contacts = adrLi.AddressEntries
numEntries = adrLi.AddressEntries.Count
nameAliasDict = {}
for i in contacts:
name = i.Name
alias = i.Address.split("=")[-1]
print i.GetExchangeUser().PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3A56101E")
我从https://msdn.microsoft.com/en-us/library/bb446002.aspx
获取财产但由于某些原因,我收到了这个错误:
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, u'Microsoft Outlook', u'The property "http://schemas.microsoft.com/mapi/proptag/0x3A550003" is unknown or cannot be found.', None, 0, -2147221233), None)
我这样做错了吗?
答案 0 :(得分:1)
您不能假设PR_CONTACT_EMAIL_ADDRESSES
或任何其他MAPI属性可用。你真的能在OutlookSpy中看到那个特定对象的属性(点击IAddrBook,“打开根容器”等)吗?
为什么你需要这个属性?你试过ExchangeUser.PrimarySmtpAddress
吗?