AppleScript Error -1728 Can't get file...
I have tried to customize the AppleScript template “Mail Rule Action” for my purposes. I want to extract the attachments from the e-mail that match a rule.
To do this, I have set up a rule in the Mail program which then calls the following script.
using terms from application "Mail"
on perform mail action with messages these_messages for rule this_rule
tell application "Mail"
set the message_count to the count of these_messages
repeat with i from 1 to the message_count
set this_message to item i of these_messages
set attachment_folder_path to (path to downloads folder) as string
tell this_message
try
repeat with att in this_message's mail attachments
set org_name to the name of att
save att in file (attachment_folder_path & org_name)
end repeat
on error error_message number errNum
display dialog "Some error: " & errNum & return & error_message
end try
end tell
end repeat
end tell
end perform mail action with messages
end using terms from
Unfortunately, I always get the following error message.
Can’t get file "Macintosh HD:Users:testuser:Downloads:test_file.pdf"
The error number is -1728.
How can I solve the problem?