首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Applescript -拖放文件附件以打开新电子邮件

Applescript -拖放文件附件以打开新电子邮件
EN

Stack Overflow用户
提问于 2010-11-22 17:43:28
回答 2查看 1.7K关注 0票数 0

有人知道Applescript片段,它会打开带有文件附件的新电子邮件,该文件附件已经拖放到Applescript脚本上了吗?(谷歌一直没有提供帮助。)

我找到了打开新邮件并提示文件附件的命令,

代码语言:javascript
复制
set theAttachment to (choose file without invisibles)

以及允许硬编码连接路径的代码片段,

代码语言:javascript
复制
set theAttachment to (((path to desktop) as string) & "myFile.jpg) as alias

但是,不允许在Applescript脚本图标上拖放文件附件。

编辑11/28/10:找到并回答MacScripter / AppleScript / OS并将其添加到下面。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-11-28 20:29:27

是在MacScripter / AppleScript / OS上给出的,它工作得很好:

代码语言:javascript
复制
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
票数 1
EN

Stack Overflow用户

发布于 2010-11-22 18:42:36

你要找的是AppleScript 开放处理程序。下面是一个简单的示例,通过为每个文件打开一个新的发送电子邮件来处理多个文件。有许多变化是可能的:

代码语言:javascript
复制
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的细节。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4248429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档