簡體   English   中英

使用 python 讀取選定 Outlook 電子郵件的內容

[英]Read contents of a selected Outlook e-mail using python

我有一段簡單的代碼,用於讀取收件箱中最后一封電子郵件的內容。

如何對在 Outlook 中單擊/突出顯示的電子郵件執行相同操作?

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

inbox = outlook.GetDefaultFolder(6) 
messages = inbox.Items
message = messages.GetLast()
print(message.body) 

只需使用ActiveExplorer().Selection(1)

例子

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application")
messages = outlook.ActiveExplorer().Selection
message = messages(1)
print(message.body)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM