使用python win32com的Outlook迭代子文件夹 [英] Outlook using python win32com to iterate subfolders

查看:100
本文介绍了使用python win32com的Outlook迭代子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,该代码使我进入了共享文件夹的收件箱以及其中的所有电子邮件.此代码效果很好,将打印上一封电子邮件的主题.

I have the following code which gets me the inbox of my shared folder, and all of the emails inside. This code works great and will print the subject of the last email.

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
recip = outlook.CreateRecipient("foo@bar.com")
inbox = outlook.GetSharedDefaultFolder(recip, 6)
messages = inbox.Items
message = messages.GetLast()
print (message.Subject)

我可以访问foo@bar.com邮箱中的其他父文件夹(例如已发送"),但是我无法在收件箱中找到该文件夹​​的任何子文件夹,或更深.因此,如果我想要inbox \ subfolder1,该如何访问?如果重要的话,请使用Outlook 2013. 我的主要目标是:

I can access other parent folders in foo@bar.com's mailbox (like Sent), but I can't get any subfolders of a folder within the inbox, or deeper than that. So if I want inbox\subfolder1, how do I access that? Using Outlook 2013 if that matters. My main goal is to do:

message.Move(inbox\subfolder1)

推荐答案

无法做到这一点-Outlook将共享的默认文件夹缓存在主OST文件中.不缓存子文件夹.如果将有问题的邮箱添加为代理存储,则应该可以使用Namespace.FoldersNamespace.Stores解析到有问题的文件夹.

Can't do that - Outlook caches shared default folders in the main OST file The subfolders are not cached. If the mailbox in question is added as a delegate store, you should be able to parse to the folder in question using Namespace.Folders or Namespace.Stores.

否则,您可以使用兑换及其

Otherwise you can use Redemption and its RDOSession.GetSharedDefaultFolder - the folder will be opened in the online mode with all of its subfolders (RDOFolder.Folders).

这篇关于使用python win32com的Outlook迭代子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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