Warm tip: This article is reproduced from serverfault.com, please click

其他-如何使用python从Outlook中的MailItem获取发件人SMTP电子邮件地址?

(其他 - How to get sender SMTP email address from MailItem in outlook using python?)

发布于 2020-12-02 13:25:48

我正在尝试使用Python和win32获取MailItem的发件人电子邮件地址,但是无论何时找到Exchange地址,我都无法获取SMTP地址。我尝试了网络上所有可用的东西,但是返回的是空字符串。这是我正在使用的代码片段:

if msg.Class == 43:
    if msg.SenderEmailType == 'EX':
      print(msg.Sender.GetExchangeUser().PrimarySmtpAddress)
    else:
      print(msg.SenderEmailAddress)
Questioner
Pranayan Metiya
Viewed
12
Dmitry Streblechenko 2020-12-02 23:43:19

你可以尝试使用读取PidTagSenderSmtpAddressMAPI属性(DASL名称http://schemas.microsoft.com/mapi/proptag/0x5D01001FMailItem.PropertyAccessor.GetProperty-使用OutlookSpy(单击IMessage按钮)或MFCMAPI查看消息