有人知道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并将其添加到下面。
发布于 2010-11-28 20:29:27
是在MacScripter / AppleScript / OS上给出的,它工作得很好:
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发布于 2010-11-22 18:42:36
你要找的是AppleScript 开放处理程序。下面是一个简单的示例,通过为每个文件打开一个新的发送电子邮件来处理多个文件。有许多变化是可能的:
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的“handlers:权威指南”( AppleScript: There )一书中,有更多关于AppleScript的细节。
https://stackoverflow.com/questions/4248429
复制相似问题