2010-11-22 99 views
0

任何人都知道Applescript會使用已在Applescript腳本上拖放的文件附件打開一封新郵件? (谷歌一直沒有幫助。)Applescript - 拖放文件附件以打開新電子郵件

我發現,打開一個新的電子郵件,並提示該文件附件命令,

set theAttachment to (choose file without invisibles) 

以及允許硬編碼路徑附件剪刀,

set theAttachment to (((path to desktop) as string) & "myFile.jpg) as alias 

但沒有允許拖放Applescript腳本圖標上的文件附件。

編輯11/28/10:找到並回答MacScripter/AppleScript | OS X並在下面添加。

回答

1

被賦予這對MacScripter/AppleScript | OS X並能正常工作:

property Myrecipient : "some email" 
property mysubject : "some subject" 
property EmailBody : "some body text" 


on run 
    tell application "Finder" 
     set sel to (get selection) 
    end tell 
    new_mail(sel) 
end run 

on open droppedFiles 
    new_mail(droppedFiles) 
end open 

on new_mail(theFiles) 
    tell application "Mail" 
     set newMessage to make new outgoing message with properties {visible:true, subject:mysubject, content:EmailBody} 
     tell newMessage 
      make new to recipient with properties {address:Myrecipient} 
      tell content 
       repeat with oneFile in theFiles 
        make new attachment with properties {file name:oneFile as alias} at after the last paragraph 
       end repeat 
      end tell 
     end tell 
     activate 
    end tell 
end new_mail 
2

你在找什麼是AppleScript open handler。這是一個簡單的例子,通過爲每個文件打開一封新的發送郵件來處理多個文件。變化的地段是可能的:

on open what 
    tell application "Mail" 
     repeat with f in what 
      set theAttachment to f 
      set theMessage to make new outgoing message with properties {visible:true, subject:"My Subject", content:"My Body"} 
      tell content of theMessage 
       make new attachment with properties {file name:theAttachment} at after last paragraph 
      end tell 
      tell theMessage 
       make new to recipient at end of to recipients with properties {name:"Some One", address:"[email protected]"} 
      end tell 
     end repeat 
    end tell 
end open 

還有很多更詳細的關於handlers在馬特·紐伯格的書的AppleScript權威指南

+0

這並不希望出於某種原因;它會打開一封新郵件但不會附加該文件。 – markratledge 2010-11-28 20:28:14