[英]Python exchangelib read mails in subfolder
I want to read the mails from the subfolder of the outlook mailbox.我想从 Outlook 邮箱的子文件夹中读取邮件。
Inbox
├──myfolder
I can read Inbox using account.inbox.all()
but i want to read mails in myfolder
我可以使用
account.inbox.all()
阅读收件箱,但我想阅读myfolder
邮件
I tried the things in folder
section of this page but i couldn't get it right我尝试了此页面
folder
部分中的内容,但无法正确完成
https://pypi.python.org/pypi/exchangelib/ https://pypi.python.org/pypi/exchangelib/
You need to get hold of the Folder
instance for myfolder
first:您需要先获取
myfolder
的Folder
实例:
my_folder = account.inbox / 'myfolder'
for i in my_folder.all():
print(i.subject)
Just in case if you have a lot of sub-folders (including nested ones) inside your directory and you want to print the subject of all then use this method.以防万一如果您的目录中有很多子文件夹(包括嵌套的)并且您想打印所有的主题,请使用此方法。
folder = account.root/'Top of Information Store'/'Inbox'/folder_name
all_folders = folder.glob('**/*')
for subfolders in all_folders:
for emails in subfolders.all():
print(emails.subject)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.