是否存在用于更改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("[email protected]")
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。