无需打开mail.app即可从剪贴板发送电子邮件

时间:2013-08-04 09:29:42

标签: applescript keyboard-maestro

我搜索了如何在不打开Apple邮件的情况下发送电子邮件,并找到问题AppleScript - How to send a email without the mail app opening up

但是,我正在使用Keyboard maestro这样做,这样我就可以在任何应用程序中使用热键发送特定的电子邮件。在谷歌搜索解决方案后,我发现这个脚本可以很好地完成工作:

tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:"hello", content:"You got a new file in your Downloads folder, girl!", visible:true}
tell theNewMessage
    make new to recipient at end of to recipients with properties {address:"myemail@mail.com"}
    send
end tell

告诉

一个问题:我想这样做,但在主题中不是 hello ,我想要剪贴板。谷歌搜索,我发现了两件事

keystroke "v" using {command down}

return (the clipboard)

我试图用这两个来替换“你好”。但它们都不起作用。

我不知道AppleScript,因此在谷歌上搜索我的问题。

2 个答案:

答案 0 :(得分:1)

这对我有用:

set a to "myemail@mail.com"
tell application "Mail"
    tell (make new outgoing message)
        set subject to (the clipboard)
        set content to "content"
        make new to recipient at end of to recipients with properties {address:a}
        send
    end tell
end tell

答案 1 :(得分:0)

这是一个恰好适合我的脚本。我只想发布它作为一个例子。

tell application "System Events"
    activate application "Mail"
    set the clipboard to "Subject Line"
    keystroke "v" using command down
    keystroke tab
    set the clipboard to "This is the contents.\nLine 2 of the contents."
    keystroke "v" using command down
end tell

点击浏览器中的电子邮件地址后,我使用此脚本。在确保文本插入点位于我的电子邮件的主题行后,我从AppleScript菜单中选择了相关的邮件脚本。