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...
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...
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
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
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.
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