首页 > 解决方案 > 搜索更多列 - Python , Outlook

问题描述

下面的代码只搜索名称。但是,我想使用更多列选项对电子邮件进行搜索。有什么办法吗?

在此处输入图像描述

import win32com.client

search_string = 'doe@doe.com'

outlook = win32com.client.gencache.EnsureDispatch('Outlook.Application')
gal = outlook.Session.GetGlobalAddressList()
entries = gal.AddressEntries
ae = entries[search_string]
email_address = None

if 'EX' == ae.Type:
    eu = ae.GetExchangeUser()
    email_address = eu.PrimarySmtpAddress

if 'SMTP' == ae.Type:
    email_address = ae.Address

print('Email address: ', email_address)

标签: pythonloopssearchoutlook

解决方案


无需搜索,您可以让 Outlook 找到匹配项 - 调用Application.Session.CreateRecipient/ Recipient.Resolve


推荐阅读