[英]How to retrieve email body of outgoing mail in apple mail using applescript?
[英]Applescript: How to paste RTF on clipboard to email on Apple Mail?
我制作了一個 Alfred 工作流程,將我的 Markdown (.md) 筆記轉換為 RTF,並在 bash 腳本中使用 pandoc 自動添加到我的剪貼板。 現在我的筆記在剪貼板上,我想提供一個選項,將剪貼板中的 RTF 粘貼到帶有 Alfred 工作流程的新電子郵件中。 Alfred 運行 osascript,所以我一直在 Mac 上使用腳本編輯器來創建我的腳本。 到目前為止我有這個:
set clipContent to the clipboard
tell application "Mail"
set newMessage to make new outgoing message with properties {visible:true, subject:"[NOTES] "}
make new cc recipient at newMessage with properties {address:"EmailAddress"}
set newMessage's content to clipContent
activate
end tell
但我收到此錯誤消息
郵件出錯:無法制作 {«class RTF »:«data RTF
關於發生了什么的任何建議?
謝謝
米
@vadian是部分正確的,盡管Mail的 AppleScript 字典指出outgoing message
的content
屬性是rich text
,但似乎只能使用純文本設置屬性。
我認為您最好實現您想要的目的是使用 GUI 腳本,以便系統⌘ V (粘貼)代表您將富文本直接粘貼到電子郵件的文本區域中。 這並不理想,但它有效:
tell application "Mail"
activate
set newMessage to make new outgoing message ¬
with properties {visible:true, subject:"[NOTES] "}
make new cc recipient at newMessage ¬
with properties {address:"EmailAddress"}
end tell
tell application "System Events"
tell process "Mail" to tell ¬
window 1 to tell ¬
scroll area 1 to tell ¬
UI element 1 to set ¬
focused to true
keystroke "v" using command down
keystroke return
end tell
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.