简体   繁体   English

OS X Mail - 在撰写模式下打开 *.eml 文件

[英]OS X Mail - Open *.eml-files in compose mode

How can I open *.eml-files in compose mode for Mac OS X Mail?如何在 Mac OS X Mail 的撰写模式下打开 *.eml 文件? For Outlook "X-Unsent: 1" seems to do the trick, but does not work for Mac OS X Mail still opens in Read-Only.对于 Outlook,“X-Unsent: 1”似乎可以解决问题,但不适用于 Mac OS X Mail 仍以只读方式打开。

This is a super old question, but obviously has received a fair number of views.这是一个非常古老的问题,但显然已经收到了相当多的意见。 My curiosity piqued, I figured I'd take a look.我的好奇心被勾起来了,我想我应该去看看。 After some fiddling around, I found you can add the following header to make a message editable:经过一番折腾,我发现您可以添加以下标头以使消息可编辑:

X-Uniform-Type-Identifier: com.apple.mail-draft

Add that to your otherwise RFC-2822 compliant message, give it a .eml or .emlx extension, and when you double-click it'll open as an editable message in Mail.app.将其添加到符合 RFC-2822 标准的邮件中,为其提供.eml.emlx扩展名,当您双击它时,它将在 Mail.app 中作为可编辑邮件打开。

Have fun.玩得开心。

In macOS Catalina 10.15.7, running the following commands from a Python script worked to open a new message and then switch to compose mode, but there is a race condition between opening the message and putting it in Compose mode if the osascript command runs too quickly.在 macOS Catalina 10.15.7 中,从 Python 脚本运行以下命令可以打开一条新消息,然后切换到撰写模式,但如果osascript命令也运行,则在打开消息和将其置于撰写模式之间存在竞争条件迅速地。 The sleep command is there to prevent the race, but you may need to adjust the length of sleep time to compensate for this. sleep命令可以防止竞争,但您可能需要调整睡眠时间的长度来弥补这一点。 (I also used time.sleep(1) in Python instead of the shell command.) (我还在 Python 中使用time.sleep(1)而不是 shell 命令。)

/usr/bin/open -a Mail path/to/tmp/message.eml
/bin/sleep 1
/usr/bin/osascript -e 'tell application "System Events" to tell application process "Mail"' -e 'keystroke "d" using {command down, shift down}' -e 'end tell'

Note that you must grant access to Terminal to control other apps, or the osascript command will fail with an error.请注意,您必须授予对终端的访问权限才能控制其他应用程序,否则osascript命令将失败并出现错误。 To do that, open System Preferences, click on the Security & Privacy item, click Accessibility from the left menu, click the lock icon to unlock the menu, then check the Terminal item (or add it if not listed) in the "Allow apps to control your computer."为此,打开系统偏好设置,单击安全和隐私项,单击左侧菜单中的辅助功能,单击锁定图标解锁菜单,然后选中“允许应用程序”中的终端项(如果未列出,则添加它)来控制你的电脑。” list.列表。

Also note that the Cmd-Shift-D keyboard shortcut sends a message that is already in compose mode, so if someone is using Mail at the time the script runs, and they have a separate compose window in the foreground, then the script could send that message instead of putting the new message in compose mode.另请注意,Cmd-Shift-D 键盘快捷键发送的消息已处于撰写模式,因此如果有人在脚本运行时使用 Mail,并且他们在前台有一个单独的撰写窗口,则脚本可以发送该消息而不是将新消息置于撰写模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM