2009-12-05 63 views
1

我已经在Apple Mail中设置了一条规则来运行“下载&打开链接”applescript。我希望这个脚本在邮件中下载url,下载后它应该打开这个文件。Applescript下载并打开链接

不知道该如何开始。下面是一个不正常的代码:

using terms from application "Mail" 
    on perform mail action with messages newMessages 
     repeat with newMessage in newMessages 

      tell application "Mail" 
       set contentLink to (content of newMessage) 
      end tell 

      set the destination_file to ("/Users/thomas/Downloads/file") 

      tell application "URL Access Scripting" 
       download contentLink to destination_file replacing yes 
      end tell 


     end repeat 
    end perform mail action with messages 
end using terms from 
+1

** **请停止添加答案提供额外的信息。只需编辑您的原始问题。 – 2011-05-11 23:55:18

+1

什么不行?你得到什么错误?你是否自己测试了不同的tell块?您应该删除自己的“答案”并编辑您的问题并在其中添加代码修订。 – markratledge 2009-12-05 18:22:37

+0

所有点数+1。这里没有足够的信息来提供解决方案。 – 2009-12-05 19:13:13

回答

0

你试图下载链接成字符串,除非你强制串入一个alias这是不可能的。你可以通过以下两种方式之一来完成这一点

  1. 要挟变量destination_file因为它初始化为一个别名...

    set the destination_file to "/Users/thomas/Downloads/file/" as POSIX file as alias 
    
  2. 强制转换,当你下载的链接变量...

    download contentLink to destination_file as POSIX file as alias replacing yes 
    

完成之后,您现在需要执行的操作是导航到下载文件的文件夹并打开它。

例子:

tell application "Finder" to open "Macintosh HD:Users:Anonymous:Downloads:example.txt" as alias