[英]Python function for changing the subject line of an Outlook mail item
是否有用於更改 Outlook 郵件項目主題行的 Python 函數?
我已經看到使用 VBA 解決這個問題。 正在尋找 python 中的函數/方法。
謝謝
更新:這是我正在嘗試的:
import win32com.client as win32
outlook = win32.gencache.EnsureDispatch('Outlook.Application')
mapi = outlook.GetNamespace('MAPI')
folder = mapi.GetDefaultFolder(6)
messages = folder.Items
# Change the current subject line to 'Testing subject change'
messages.GetFirst().Subject = 'Testing subject change'
但是,主題行不會改變。 我應該使用任何特定功能嗎?
這段簡短的代碼將替換指定文件夾中所有電子郵件的所有主題行,在本例中為“草稿”(前提是您的辦公室是英文的)
import win32com.client as win32
outlook = win32.Dispatch("Outlook.Application").GetNamespace("MAPI")
acc = outlook.Folders("myaddress@provider.com")
eMailFolder = acc.folders("Drafts") #This is the localized name of your folder, as it appears in Outlook's GUI
def replaceSubjectLine(email:object):
print(email.Subject)
email.Subject = "This is the new subject line"
email.Save
print(email.Subject)
for message in eMailFolder.Items:
replaceSubjectLine(message)
在短:你在的MailItem對象成Python讀,然后改變了其屬性(主題)中的一個,但你永遠不.Save
的改變的MailItem到Outlook。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.