任何人都知道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并在下方添加。
答案 0 :(得分: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:"someone@somewhere"}
end tell
end repeat
end tell
end open
Matt Neuberg的书 AppleScript:The Definitive Guide 中有关于handlers
的详细信息。
答案 1 :(得分: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