0

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

2 回答 2

1

因为唯一改变消息的行是

set subject of theMsg to the mysubject as string

看来这可能是 Exchange 的问题。您是否尝试过在另一封电子邮件到达时简单地设置其主题?

于 2012-08-29T05:07:59.603 回答
0

好的,问题已通过添加解决

delay(3)

就在之前

set subject of theMsg to the mysubject as string

于 2012-08-29T18:47:25.293 回答