简体   繁体   English

AppleScript将照片附加到打开的邮件消息的末尾

[英]AppleScript to attach photo to end of open Mail message

In Dec. 2012, Mark Hunte of this stackoverflow site helped another user by providing the following AppleScript. 在2012年12月,此stackoverflow网站的Mark Hunte通过提供以下AppleScript帮助了另一个用户。 The script creates a new email msg. 该脚本将创建一个新的电子邮件消息。 and attaches a file to the end. 并将文件附加到末尾。

Could anyone here please help me? 有人可以帮我吗? I need to have a shortened version of this script that only does one thing: attach a file named "selectedPhoto.jpg" to the end of an already open email. 我需要此脚本的简化版本只能执行以下操作:将名为“ selectedPhoto.jpg”的文件附加到已打开的电子邮件的末尾。

That is, if I am creating a new email or replying to an email and already have the window open, I would like to run a script that simply attaches a photo to the end of that email. 也就是说,如果我正在创建新电子邮件或回复电子邮件,并且已经打开窗口,那么我想运行一个脚本,该脚本只是将照片附加到该电子邮件的末尾。

I have tried taking out lines of the following script, but I can't get it to work. 我尝试取出以下脚本的几行,但无法正常工作。

I am running OS X 10.8 我正在运行OS X 10.8

Can someone help? 有人可以帮忙吗?


set theAttachment1 to POSIX file "/Users/USERNAME/Desktop/Desktop--IMAGE/scooter-6.jpg"

tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:"subject", content:"the_content" & return & return}
    tell newMessage

        set visible to false
        set sender to "myaddress@btinternet.com"
        make new to recipient at end of to recipients with properties {address:"someAddress@btinternet.com"}
        make new attachment with properties {file name:theAttachment1} at after the last paragraph

        (* change save to send to send*)
        save --<<<<---------------- change save to send to send
        (* change save to send to send*)
    end tell
end tell

I couldn't get tell outgoing message 1 to make new attachment to work, but you could use UI scripting: 我无法tell outgoing message 1 to make new attachment ,但可以使用UI脚本:

set old to the clipboard as record
set f to "/Library/Desktop Pictures/Antelope Canyon.jpg"
set the clipboard to (read (POSIX file f as alias) as JPEG picture)
activate application "Mail"
tell application "System Events" to keystroke "v" using command down
set the clipboard to old

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

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