我在工作中被迫使用 Outlook for Mac 连接到公司 Exchange,并且我拼凑了一个小的 AppleScript 来更改来自我们监控系统的传入电子邮件的主题行。默认情况下,它们的长度很长,人类不可读。我正在尝试解决这个问题。
该脚本可以工作,但是由于某些奇怪的原因,当我自己发送测试消息时一切都运行良好,但是当来自监控系统的真实消息进入时,所有更改都会恢复!当邮件到达我的邮箱时,主题正是我想要的,但在 3-5 秒内它又恢复到原来的主题!
我对 AppleScript 一无所知,也不知道在哪里解决这样的问题。
有人请看一下并告诉我我正在尝试做的事情是否可行?
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to "" & subject
set text item delimiters of AppleScript to prevTIDs
return subject
end replaceText
tell application "Microsoft Outlook"
set theMessages to the current messages
end tell
repeat with theMsg in theMessages
tell application "Microsoft Outlook"
set mysubject to get the subject of theMsg
if mysubject contains "[Subscription:Spectrum CTO] SPECTRUM - " then
set mysubject to my replaceText("[Subscription:Spectrum CTO] SPECTRUM - ", "", mysubject)
set mysubject to my replaceText("Alarm Title: ", "", mysubject)
set mysubject to my replaceText("Severity: ", "", mysubject)
set mysubject to my replaceText("Model Name:", "-", mysubject)
set subject of theMsg to the mysubject as string
end if
end tell
end repeat