【问题标题】:How authentication works while reading outlook emails with python and win32com使用 python 和 win32com 阅读 Outlook 电子邮件时身份验证的工作原理
【发布时间】:2018-03-18 03:31:15
【问题描述】:

我知道我们可以使用以下代码(Reading e-mails from Outlook with Python through MAPI)从 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.GetLast()
body_content = message.body
print body_content

但我们没有在上述代码的任何地方提供用户名和密码。 那么代码是如何验证outlook账号的呢。

任何人都可以在这里解释身份验证是如何发生的吗?

【问题讨论】:

标签: python email outlook win32com


【解决方案1】:

win32com.client 正在与Outlook COM object 交互。由于 Outlooksingleton,因此您实际上是在生成 Outlook 的“隐藏”实例。请记住,每次登录 Outlook 时都不需要输入用户名和密码。这就是为什么这里也不需要用户名和密码的原因。

而且,只要打开 Outlook 的 COM 对象,就无法通过“exlporer”打开 Outlook。这是因为只允许一个 Outlook 实例。您可能会注意到,虽然您从未打开过 Outlook 的 GUI,但您仍然会收到新电子邮件的弹出消息。

【讨论】:

    猜你喜欢
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 2021-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    相关资源
    最近更新 更多