使用Python获取Outlook待办事项列表

使用Python获取Outlook待办事项列表,第1张

概述使用Python获取Outlook待办事项列表

我使用win32com模块访问Outlook。

我想抓住任务并标记邮件 – Outlook有很多不同的名字,并且针对不同types的“对象”来看待它们。 但是,我想要获取任务主题列表以及在按任务/待办事项列表 (Outlook 2010)时显示的截止date。

@utapyngo想出了一个非常有用的C#代码示例 – 但我真的需要一些帮助翻译它为Python。

httpWebResponse原始响应,使用reflection

为什么Textpad会问你是否要使用POSIX正则Expression式语法?

如何防止在windows(7)中开发Ruby时出现PATH错误? 难道我做错了什么?

将新的一组值添加到ArrayList

为什么没有Microsoft.Win64命名空间?

Outlook.nameSpace ns = null; Outlook.MAPIFolder todoFolder = null; Outlook.Items todoFolderItems = null; Outlook.TaskItem task = null; Outlook.ContactItem contact = null; Outlook.Mailitem email = null; string todoString = string.Empty; try { ns = OutlookApp.Session; todoFolder = ns.GetDefaultFolder(Outlook.olDefaultFolders.olFolderTodo); todoFolderItems = todoFolder.Items; for (int i = 1; i <= todoFolderItems.Count; i++) { object outlookItem = todoFolderItems[i]; if (outlookItem is Outlook.Mailitem) { email = outlookItem as Outlook.Mailitem; todoString += String.Format("Email: {0} Due:{1}{2}",email.Subject,email.TaskDueDate,Environment.Newline); } else if (outlookItem is Outlook.ContactItem) { contact = outlookItem as Outlook.ContactItem; todoString += String.Format("Contact: {0} Due:{1}{2}",contact.Fullname,contact.TaskDueDate,Environment.Newline); } else if (outlookItem is Outlook.TaskItem) { task = outlookItem as Outlook.TaskItem; todoString += String.Format("Task: {0} Due: {1}{2}",task.Subject,task.DueDate,Environment.Newline); } else MessageBox.Show("UnkNown Item type"); Marshal.ReleaseComObject(outlookItem); } MessageBox.Show(todoString); } finally { if (todoFolderItems != null) Marshal.ReleaseComObject(todoFolderItems); if (todoFolder != null) Marshal.ReleaseComObject(todoFolder); if (ns != null) Marshal.ReleaseComObject(ns); }

Common files对话框和Common Item对话框在c ++中的主要区别是什么?

从iOS(iPad)到windows的端口游戏

Powershell从发生$ N次的IP数组中创build一个以逗号分隔的列表

在Java程序中启用/禁用IPv6 windows设置

有没有办法使用_snprintf_s来确定目标缓冲区大小?

这里是一篇文章 ,解释一切:

“待办事项”与任务很容易混淆,但请记住“待办事项”可以是电子邮件,联系人或任务。 一旦Outlook将其标记为后续项目,Outlook项目就成为待办事项。 要获取待办事项列表,请使用Outlook命名空间对象获取对默认待办事项文件夹的引用。 但要小心,在访问它们的属性之前,你需要检查对象的类型!

它在C#中也有很多例子。 如果你有win32com的经验,你应该可以把它们翻译成Python。

编辑 :这是其中之一翻译:

import sys import win32com.clIEnt olFolderTodo = 28 outlook = win32com.clIEnt.dispatch("outlook.application") ns = outlook.Getnamespace("MAPI") todo_folder = ns.GetDefaultFolder(olFolderTodo) todo_items = todo_folder.Items def print_encoded(s): print s.encode(sys.stdout.enCoding,'replace') for i in range(1,1 + len(todo_items)): item = todo_items[i] if item.__class__.@R_419_4267@ == '_Mailitem': print_encoded(u'Email: {0}. Due: {1}'.format(item.Subject,item.TaskDueDate)) elif item.__class__.@R_419_4267@ == '_ContactItem': print_encoded(u'Contact: {0}. Due: {1}'.format(item.Fullname,item.TaskDueDate)) elif item.__class__.@R_419_4267@ == '_TaskItem': print_encoded(u'Task: {0}. Due: {1}'.format(item.Subject,item.DueDate)) else: print_encoded(u'UnkNown Item type: {0}'.format(item))

编辑 :修复编码问题

总结

以上是内存溢出为你收集整理的使用Python获取Outlook待办事项列表全部内容,希望文章能够帮你解决使用Python获取Outlook待办事项列表所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1276036.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存