3

我有一个 AppleScript 可以很好地整理信息并创建带有附件的电子邮件。

我找不到脚本将消息格式设置为接收收件箱所需的“纯文本”(而不是默认的“富文本”)的方法。

是否有 AppleScript 方法(或技巧)将消息格式设置为“纯文本”?

4

3 回答 3

2

我在试图解决这个问题时发现了这个问题。最终我想出了以下解决方案:

tell application "Mail"
    set newMessage to make new outgoing message 
        with properties {visible:true,
                         subject:"message title",
                         sender:"sender@from.address",
                         content:mailBody}
    tell newMessage
        make new to recipient with properties {address:"mail@recipient.com"}
    end tell
    activate
end tell

tell application "System Events"
    click menu item "Make Plain Text" of ((process "Mail")'s (menu bar 1)'s (menu bar item "Format")'s (menu 1))
end tell

希望有人会发现这很有用,我知道我会在几个小时前!

这在 Mail 版本 7.3 和 12.4 上进行了测试。较新或较旧的版本可能需要不同的菜单标题。

于 2014-09-11T21:48:39.060 回答
0

在脚本中创建消息的部分之前,添加此行。

 tell application "Mail" to set default message format to plain text

在脚本的最后添加这个来重置值

 tell application "Mail" to set default message format to rich text
于 2012-08-28T15:55:32.507 回答
0

您可以使用键盘快捷键⌘</kbd>shiftt also to change the message format to plain text:

tell application "System Events" to keystroke "t" using {command down, shift down}

在邮件版本 12.4 中测试

于 2020-02-12T01:09:54.570 回答