如何从 'user.GetDirectReports()' 检索电子邮件地址?
How to retrieve email address from 'user.GetDirectReports()'?
以下行用于检索给定人员(按电子邮件地址)直线经理的电子邮件地址:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
gal = outlook.Session.GetGlobalAddressList()
entries = gal.AddressEntries
chk_email = ['david@company.com']
for chk in chk_email:
for e in entries:
user = e.GetExchangeUser()
if user is not None and chk == user.PrimarySmtpAddress.lower():
print (user.GetDirectReports())
# It prints:
# <win32com.gen_py.Microsoft Outlook 16.0 Object Library.AddressEntries instance at 0x2115795695424>
# then, added lines but returned nothing
for recipient in user.GetDirectReports():
print (recipient) # returns nothing
recipient.Resolve()
print (recipient.AddressEntry()) # returns nothing
print (recipient.AddressEntry.Address) # returns nothing
print (recipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress()) # returns nothing
以上案例 David 有一位直线经理。
我也试过另一个,Nancy,直线经理也是下属。在这一行中,它显示错误:
recipient.Resolve()
AttributeError: '<win32com.gen_py.Microsoft Outlook 16.0 Object Library.AddressEntry instance at 0x2242384456894>' object has no attribute 'Resolve'
如何 get/interpret 直线经理的电子邮件地址 'xxxx@xxxx.com' 表格?
我也试过 user.GetExchangeUserManager()
它 returns ''。
当然 - 您会得到类型为 AddressEntries
的 COM 对象。您需要遍历其条目。
永远不要循环遍历 GAL 中的所有条目 - 调用 Namespace.CreateRecipient
/ Recipient.Resolve
,然后使用 Recipient.AddressEntry
.
以下行用于检索给定人员(按电子邮件地址)直线经理的电子邮件地址:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
gal = outlook.Session.GetGlobalAddressList()
entries = gal.AddressEntries
chk_email = ['david@company.com']
for chk in chk_email:
for e in entries:
user = e.GetExchangeUser()
if user is not None and chk == user.PrimarySmtpAddress.lower():
print (user.GetDirectReports())
# It prints:
# <win32com.gen_py.Microsoft Outlook 16.0 Object Library.AddressEntries instance at 0x2115795695424>
# then, added lines but returned nothing
for recipient in user.GetDirectReports():
print (recipient) # returns nothing
recipient.Resolve()
print (recipient.AddressEntry()) # returns nothing
print (recipient.AddressEntry.Address) # returns nothing
print (recipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress()) # returns nothing
以上案例 David 有一位直线经理。
我也试过另一个,Nancy,直线经理也是下属。在这一行中,它显示错误:
recipient.Resolve()
AttributeError: '<win32com.gen_py.Microsoft Outlook 16.0 Object Library.AddressEntry instance at 0x2242384456894>' object has no attribute 'Resolve'
如何 get/interpret 直线经理的电子邮件地址 'xxxx@xxxx.com' 表格?
我也试过 user.GetExchangeUserManager()
它 returns '
当然 - 您会得到类型为 AddressEntries
的 COM 对象。您需要遍历其条目。
永远不要循环遍历 GAL 中的所有条目 - 调用 Namespace.CreateRecipient
/ Recipient.Resolve
,然后使用 Recipient.AddressEntry
.