Hi all
OSX 10.11.6
The script below - in a previous version successfully saved all attachments from the emails in this (example) Mail folder.
tell application "Mail"
activate
try
set emailCount to count of messages of mailbox mailBoxName of mailbox catName
set attachmentCount to 0
set errorCount to 0
repeat with i from 1 to emailCount
set theMessage to item i of messages of mailbox mailBoxName of mailbox catName
set theAttachments to every mail attachment of theMessage
repeat with a from 1 to length of theAttachments
set theAttachment to item a of theAttachments
try
set theAttachmentName to name of theAttachment
set theSavePath to attFolder & ":" & theAttachmentName
**save theAttachment in theSavePath**
set attachmentCount to attachmentCount + 1
on error errMsg number errNum
set errorCount to errorCount + 1
end try
end repeat
end repeat
display dialog "Saved " & attachmentCount & " files, with " & errorCount & " errors" with title "Attachment Report" buttons "OK"
on error errMsg number errNum
display dialog "No message selected or error " & return & errNum & space & errMsg ¬
buttons {"Quit"} default button 1 with title emailApp
return {false, "", ""}
end try
end tell
Now I get “Mail got an error: AppleEvent handler failed.” on the statement save theAttachment in theSavePath.
All the variables for the mail folders and the save folder are defined.
here is an example of the output:
etc:etc:Master:Construction Research:Extension of IFC Standard for Victorian Cadastre:ATT Email Attachments:Report_ver0.3_7-10-2016.docx.
Any clues?