Edit : On Mavericks you need to replace :
save theAttachment in theFileName
with
save theAttachment in file theFileName
Thank you : this makes the script work indeed, I can save to whatever folder I want,
MANUALLY (from Applescript Editor), when using :
tell application "Mail"
set myMessages to selection
tell me to perform mail action with messages myMessages
end tell
However, the Mail rule does not work.
Here is my Mail rule :
"Attachment" is "Image"
"Run Applescript" : "PJ images"
And here is the script :
Code:
using terms from application "Mail"
on perform mail action with messages theMessages -- for rule theRule
set theOutputFolder to "MBPHD:Users:bruno:Desktop:"
tell application "Mail"
repeat with theMessage in theMessages
if theMessage's mail attachments is not {} then
repeat with theAttachment in theMessage's mail attachments
set theFileName to theOutputFolder & theAttachment's name
try
save theAttachment in file theFileName
on error errnum
end try
end repeat
end if
end repeat
end tell
end perform mail action with messages
end using terms from
EDIT : pfuuuuuuu..... finally figured out what the issue is :
Drum rolls....
DOES NOT work with POP accounts
WORKS FINE with IMAP accounts !!
Thank you for your help.
Note : there is no need to use the disk name :
set theOutputFolder to "Users:bruno:Folder:" works as well.