2013-05-05 80 views
0

2012年12月,此stackoverflow站點的Mark Hunte通過提供以下AppleScript幫助了另一位用戶。該腳本創建一個新的電子郵件消息。並將文件附加到最後。AppleScript將照片附加到打開郵件的末尾

任何人都可以幫我嗎?我需要一個縮短版本的腳本,只做一件事:將一個名爲「selectedPhoto.jpg」的文件附加到已經打開的電子郵件的末尾。

也就是說,如果我正在創建新電子郵件或回覆電子郵件並已打開窗口,我想運行一個腳本,只需將該照片附加到該電子郵件的末尾即可。

我已經嘗試拿出以下腳本的行,但我無法讓它工作。

我正在運行OS X 10.8

有人可以幫忙嗎?


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 "[email protected]" 
     make new to recipient at end of to recipients with properties {address:"[email protected]"} 
     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 

回答

0

我不能讓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