Applescript:邮件签名的怪异

时间:2015-02-24 14:24:23

标签: email applescript

我正在编写一个AppleScript脚本,用作电子邮件合并,从Numbers文档(名称,电子邮件地址,许可证代码,促销代码)中获取信息,并在Mail中生成电子邮件。插入基座后动态内容,发生一些文本格式化(使文本加粗,红色或蓝色)。代码有效,但一旦编辑了某些内容,消息签名就会消失。签名就在那里,但几秒钟后就消失了。

但是,如果我在行上设置断点(使用脚本调试器),则设置了消息签名,它可以正常工作。下面是一个示例代码,说明了这一点:

    tell application "Mail"
        set theMsg to (make new outgoing message with properties {subject:"Test", content:"Wahoo", visible:false})
        tell theMsg
            make new to recipient with properties {name:"Josh Booth", address:"none@none.com"}
            set character 1 to "Y"
            set color of character 1 to {60000, 1, 1}
        end tell
        set theMsg's message signature to signature "JB_SocialMedia"
        log "Fin"
    end tell

此外,即使属性visible设置为false,它仍会显示。在OS X Yosemite上运行,但这个问题也发生在小牛队。

有什么想法?

1 个答案:

答案 0 :(得分:0)

使用消息创建签名。

tell application "Mail"
    set theMsg to (make new outgoing message with properties {subject:"Test", content:"Wahoo", visible:false, message signature:signature "JB_SocialMedia"})
    tell theMsg
        make new to recipient with properties {name:"Josh Booth", address:"none@none.com"}
        set character 1 to "Y"
        set color of character 1 to {60000, 1, 1}
    end tell
    log "Fin"
end tell