首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不保存对AppleScript邮件所做的更改

不保存对AppleScript邮件所做的更改
EN

Stack Overflow用户
提问于 2012-08-29 12:27:18
回答 2查看 653关注 0票数 0

我被迫在工作时使用连接到公司Exchange的Outlook for Mac,我拼凑了一个小AppleScript来更改来自我们监控系统的传入电子邮件的主题行。默认情况下,它们的长度太长,人类无法阅读。我正在尝试解决这个问题。

脚本可以工作,但是由于某种奇怪的原因,当我自己发送测试消息时,一切都运行得很好,但是当来自监控系统的真实消息进来时,所有的更改都会恢复过来!当邮件到达我的邮箱时,主题完全是我想要的,但在3-5秒内它就会恢复到原来的主题!

我对AppleScript一无所知,也不知道从哪里开始解决这样的问题。

请任何人看一看,并告诉我,我正在尝试做的事情是否可行?

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-30 02:47:25

好的,这个问题是通过添加

delay(3)

就在这之前

set subject of theMsg to the mysubject as string

票数 0
EN

Stack Overflow用户

发布于 2012-08-29 13:08:00

因为修改消息的唯一行是

代码语言:javascript
复制
set subject of theMsg to the mysubject as string

似乎这可能是Exchange的一个问题。当另一封邮件到达时,你有没有尝试过简单地设置它的主题?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12170878

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档