在python w/Outlook 2007中,使用win32com和/或active_目录,如何获取对子文件夹的引用,以便可以将邮件项目移动到此子文件夹?
我的收件箱结构如下:
Inbox | +-- test | `-- todo
我可以访问收件箱文件夹,如:
import win32com.client
import active_directory
session = win32com.client.gencache.EnsureDispatch("MAPI.session")
win32com.client.gencache.EnsureDispatch("Outlook.Application")
outlook = win32com.client.Dispatch("Outlook.Application")
mapi = outlook.GetNamespace('MAPI')
inbox = mapi.GetDefaultFolder(win32com.client.constants.olFolderInbox)
print '\n'.join(dir(inbox))
但是当我试图获取每个Microsoft's example的子目录test
时,inbox
对象没有Folders
接口或任何获取子目录的方法。
如何获得指向Folder
subdir的test
对象?
这对我来说很有用,可以将邮件项移动到“test”子目录中(通过去掉gencache的内容来简化):
对我有用的是遍历文件夹名。(当我发布这个问题时,我不知道文件夹的名称)。
我意识到这是一个老问题,但我最近一直在使用win32com软件包,发现文档很麻烦,至少可以这么说……我希望有人,有一天能拯救我在试图理解MSDN的解释时所经历的混乱
下面是一个python脚本的示例,它可以遍历Outlook文件夹,在我需要的地方访问电子邮件。
免责声明 我在代码周围移动了一下,取出了一些敏感信息,所以如果你想复制粘贴并运行它,祝你好运。
希望这不会弊大于利。
相关问题 更多 >
编程相关推荐