使用 AppleScript 将邮件消息设置为纯文本
我有一个 AppleScript,它可以很好地整理信息并创建带有附件的电子邮件.
I have an AppleScript that nicely collates information and creates an email message with attachments.
我找不到脚本将消息格式设置为接收收件箱所需的纯文本"(而不是默认的富文本")的方法.
I cannot find a way for the script to set the message format to "Plain Text" which is required by the receiving inbox (rather than the default "Rich Text").
是否有 AppleScript 方法(或技巧)可以将消息格式设置为纯文本"?
Is there an AppleScript way (or trick) to setting the message format to "Plain Text"?
我在尝试解决这个问题时发现了这个问题.最终我想出了以下解决方案:
I found this question while trying to solve exactly this problem. Eventually I came up with the following solution:
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
希望有人会觉得这很有用,我知道我几个小时前就会有!
Hopefully someone will find this useful, I know I would have several hours ago!
这是在邮件版本 7.3 和 12.4 上测试的.较新或较旧的版本可能需要不同的菜单标题.
This is tested on Mail versions 7.3 and 12.4. Newer, or older, versions might need different menu titles.