不保存AppleScript对Outlook邮件的更改

时间:2012-08-29 04:27:18

标签: macos outlook applescript

我被迫在工作中使用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

2 个答案:

答案 0 :(得分:1)

由于唯一改变消息的行是

set subject of theMsg to the mysubject as string

似乎它可能是Exchange的一个问题。您是否尝试过在收到其他电子邮件时设置主题?

答案 1 :(得分:0)

好的,通过添加

解决了这个问题

delay(3)

之前

set subject of theMsg to the mysubject as string