我正在尝试使用Python遍历Outlook并获取所有来自特定发件人的电子邮件。我已经进行了搜索,但无法找到如何实现这一点的方法。我可以通过主题获取电子邮件并返回发件人,但我希望获取所有发件人然后返回主题?以下是我用于按主题获取发件人的代码:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
messages = inbox.Items
message = messages("Test 08/18/14")
print(message.sender)
这将返回主题为“Test 08/19/14”的邮件的发件人。
我想查看我的电子邮件,并获取特定发件人的所有电子邮件主题。