我被迫在工作时使用连接到公司Exchange的Outlook for Mac,我拼凑了一个小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发布于 2012-08-30 02:47:25
好的,这个问题是通过添加
delay(3)
就在这之前
set subject of theMsg to the mysubject as string
发布于 2012-08-29 13:08:00
因为修改消息的唯一行是
set subject of theMsg to the mysubject as string似乎这可能是Exchange的一个问题。当另一封邮件到达时,你有没有尝试过简单地设置它的主题?
https://stackoverflow.com/questions/12170878
复制相似问题