Python Outlook:阅读其他邮箱的收件箱 [英] Python Outlook: Read Inbox of additional mailbox

查看:72
本文介绍了Python Outlook:阅读其他邮箱的收件箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Outlook 2010 - 并且有我的主邮箱:name@company.com

I'm using Outlook 2010 - and have my main mailbox: name@company.com

我还在我的个人资料中添加了另一个邮箱:mb data proc

I have also added another mailbox to my profile: mb data proc

两者都在 Outlook 中显示为顶级文件夹:

Both appear as top level folders within Outlook:

name@company.com
-Inbox
-Sent Items
-Deleted Items

mb data proc
-Inbox
-Sent Items
-Deleted Items

我无法为附加邮箱创建不同的配置文件.它已添加到同一配置文件中.

I cannot create a different profile for the additional mailbox. It has been added in the same profile.

如何获得对mb data proc"邮箱中收件箱的引用?

How do I get a reference to the Inbox in the "mb data proc" mailbox?

这与此处描述的问题相同 获取对其他收件箱的引用 但是这在 VBS 中.

This is the same problem as described here Get reference to additional Inbox but this in VBS.

在python中怎么做?

How to do in python?

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder=outlook.Folders("mb data proc")
msg=folder.Items
msgs=msg.GetLast()
print msgs    

我试过了,但出现此错误:

I tried this but I get this error:

       folder=outlook.Folders("mb data proc")
AttributeError: _Folders instance has no __call__ method

推荐答案

我也有类似的疑问,据我了解,此处所述的解决方案适用于 Python 2.7

I had a similar doubt and as I understand it the solution stated here is for Python 2.7

关于如何使用 Python 3.+ 版本操作它,我将尽量使其易于理解.

I will try to make it understandable regarding how to operate it using Python 3.+ versions.

import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder = outlook.Folders.Item("Mailbox Name")
inbox = folder.Folders.Item("Inbox")
msg = inbox.Items
msgs = msg.GetLast()
print (msgs)
print (msgs.Subject)

由于 _Folder 不可调用,您需要使用 Python 3+ 中的 Folders.Item() 方法来引用您的邮箱.

Since _Folder is not callable, you need to use Folders.Item() method in Python 3+ to reference your mailbox.

希望有帮助.谢谢!

这篇关于Python Outlook:阅读其他邮箱的收件箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆