使用AppleScript将邮件设置为纯文本

问题描述 投票:3回答:3

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

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

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

applescript plaintext apple-mail
3个回答
2
投票

我在尝试完全解决此问题时发现了这个问题。最终我想到了以下解决方案:

tell application "Mail"
    set newMessage to make new outgoing message 
        with properties {visible:true,
                         subject:"message title",
                         sender:"[email protected]",
                         content:mailBody}
    tell newMessage
        make new to recipient with properties {address:"[email protected]"}
    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

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

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


0
投票

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

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

在脚本的最后添加此值以重置值

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

0
投票

您可以使用键盘快捷键 shift t还将消息格式更改为plain text

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

在邮件版本12.4中测试]


-1
投票

我不确定是否可以使用这种方法:

© www.soinside.com 2019 - 2024. All rights reserved.