仅获取特定日期邮件
我使用以下代码获取“已发送项目”。它正在获取所有发送的邮件。我只想获取特定的日期邮件。
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder = outlook.Folders("[email protected]")
sent_items = folder.Folders.Item("Sent Items")
sent_messages = sent_items.Items
for msg in sent_messages:
received_date = msg.SentOn.strftime("%d-%m-%y")
print(received_date)
I used following code to get 'Sent Items'. It is fetching all sent mails. I want to fetch particular date mails only.
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder = outlook.Folders("[email protected]")
sent_items = folder.Folders.Item("Sent Items")
sent_messages = sent_items.Items
for msg in sent_messages:
received_date = msg.SentOn.strftime("%d-%m-%y")
print(received_date)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
查找
/findnext
或限制
items
类的方法。在这种情况下,您只能处理与您的条件相对应的项目。在以下文章中阅读有关它们的更多信息:注意,以确保按照Microsoft Outlook期望的那样格式化日期时间比较字符串,请使用
格式
功能在大多数编程语言中可用(或其在编程语言中等效)。以下示例创建了一个喷气式过滤器,以查找2022年6月12日之前在当地时间3:30之前修改的所有项目。请参阅使用日期时间比较过滤项目以获取更多信息。
You can use the
Find
/FindNext
orRestrict
methods of theItems
class for that. In that case you can deal with items that correspond to your conditions only. Read more about them in the following articles:Note, to make sure that the date-time comparison string is formatted as Microsoft Outlook expects, use the
Format
function available in most programming languages (or its equivalent in your programming language). The following example creates a Jet filter to find all items that have been modified before June 12, 2022 at 3:30 PM local time.See Filtering Items Using a Date-time Comparison for more information.