【发布时间】:2012-08-23 03:30:07
【问题描述】:
我有一个 AppleScript,它可以很好地整理信息并创建带有附件的电子邮件。
我找不到脚本将消息格式设置为接收收件箱所需的“纯文本”(而不是默认的“富文本”)的方法。
是否有 AppleScript 方法(或技巧)将消息格式设置为“纯文本”?
【问题讨论】:
标签: applescript plaintext apple-mail
我有一个 AppleScript,它可以很好地整理信息并创建带有附件的电子邮件。
我找不到脚本将消息格式设置为接收收件箱所需的“纯文本”(而不是默认的“富文本”)的方法。
是否有 AppleScript 方法(或技巧)将消息格式设置为“纯文本”?
【问题讨论】:
标签: applescript plaintext apple-mail
在脚本中创建消息的部分之前,添加此行。
tell application "Mail" to set default message format to plain text
在脚本的最后添加这个来重置值
tell application "Mail" to set default message format to rich text
【讨论】:
Mail got an error: Can’t make string into type constant.
set default message format to plain text 更改为 set default message format to plain format 这将编译并运行 - 但不幸的是,该消息仍在富文本中。
Content-Type: TEXT/HTML;。如果我手动发送带有从 Mail.app 中选择的纯文本的消息,标题将仅包含 Content-Type: text/plain;。
我在尝试解决这个问题时发现了这个问题。最终我想出了以下解决方案:
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 上测试的。新旧版本可能需要不同的菜单标题。
【讨论】:
您也可以使用键盘快捷键 ⌘shiftt 将消息格式更改为 plain text:
tell application "System Events" to keystroke "t" using {command down, shift down}
在邮件版本 12.4 中测试
【讨论】: