views:

178

answers:

5

I've set a rule in Apple Mail to run a "Download & Open link" applescript. I would like this script to download the url in the mail message and after downloading it should open the file.

No idea how to start on this...

A: 

Here's my code, it's almost working.

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 message of newMessage) as string)
  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

  -- open the file somehow


 end repeat
end perform mail action with messages
end using terms from
tdskate
A: 

Still not working :(

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
tdskate
+1  A: 

What does't work? What errors are you getting? Have you tested the different tell blocks by themselves?

You should delete your own "answers" and edit your question and add code revisions there.

songdogtech
+1 on all points made. There isn't nearly enough information here to provide a solution.
Philip Regan
A: 

This code works, but won't rename & open the file properly...

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
tdskate
A: 

Do you have a final script that I could take a look at?

Erik