The save line throws always an error.
I tried to put the Scripting Additions commands out of the scope of Mail and also specified the path as POSIX path.
No success.
Is there any work around for this in the short time? I am playing with the idea of forwarding the emails to a box net folder that is synced on my desktop but it is not as clean as this script was.
Do any other mail applications offer the ability to save attachments automatically?
Can someone help my upgrade the script so that it works with MaxOS Sierra ? 😛
Currently this script does not function correctly anymore and when I initiate the rule in Mail.app that runs this script, I get this error in the console :
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
set dt to path to desktop
#set outputPath to (dt as rich text) & "Incoming OCR:"
set outputPath to "/Users/john/Incoming OCR/"
set x to 1
repeat with thisMessage in theMessages
tell mail attachments of thisMessage to set {attachs, cnt} to {it, count it}
set y to 1
repeat with thisItem in attachs
try
if MIME type of thisItem is "application/pdf" and file size of thisItem > 2000 then
tell ((date received of thisMessage) as «class isot» as string) to ¬
tell ((date received of thisMessage) as «class isot» as string) to ¬
rich text 1 thru 4 & "-" & rich text 6 thru 7 & "-" & rich text 9 thru 10 & "-" & ¬
rich text 12 thru 13 & "." & rich text 15 thru 16
save thisItem in (POSIX file (outputPath & result & "-#" & file size of thisItem & ".pdf"))
set y to y + 1
end if
if MIME type of thisItem is "image/jpeg" and file size of thisItem > 30000 then
tell ((date received of thisMessage) as «class isot» as string) to ¬
tell ((date received of thisMessage) as «class isot» as string) to ¬
rich text 1 thru 4 & "-" & rich text 6 thru 7 & "-" & rich text 9 thru 10 & "-" & ¬
rich text 12 thru 13 & "." & rich text 15 thru 16
save thisItem in (POSIX file (outputPath & result & "-#" & file size of thisItem & ".jpg"))
set y to y + 1
end if
end try
end repeat
set x to x + 1
end repeat
end perform mail action with messages
end using terms from