- Joined
- May 28, 2023
- Messages
- 5
- Reaction score
- 2
Hi All.
First, I would like to thank profusely Matt Swain who wrote the script in 2011. I am trying to get this script to work under Ventura 13.3.1. The script appears in the link below:
http://www.macosxtips.co.uk/index_files/automatically-save-mail-attachments-using-applescript.php
I have the script as this:
My rule for running this script is as shown in the screenshot attached. The example.com address is a dummy address (Duh!)
No matter what I do, I cannot get this script to work. It doesn't work when the message first arrives in my inbox nor does it work if I select the message and select "Apply Rules". I have checked the spelling of the default saving folder name agains the name in the script. It is all correct. When I compile the script, there are NO errors.
Can someone PLEASE help me to get this to work. It would be IMMENSELY appreciated.
First, I would like to thank profusely Matt Swain who wrote the script in 2011. I am trying to get this script to work under Ventura 13.3.1. The script appears in the link below:
http://www.macosxtips.co.uk/index_files/automatically-save-mail-attachments-using-applescript.php
I have the script as this:
AppleScript:
on perform_mail_action(ruleData)
-- From http://www.macosxtips.co.uk/index_files/automatically-save-mail-attachments-using-applescript.php
-- The folder to save the attachments in (must already exist)
set attachmentsFolder to (system attribute "HOME") & "/Mail Attachments/"
-- Save in a sub-folder based on the name of the rule in Mail
set subFolder to name of |Rule| of ruleData as text
tell application "Finder"
if not (exists folder subFolder of folder attachmentsFolder) then
make new folder at attachmentsFolder with properties {name:subFolder}
end if
end tell
-- Get incoming messages that match the rule
tell application "Mail"
set selectedMessages to |SelectedMessages| of ruleData
repeat with theMessage in selectedMessages
-- Get the date the message was sent
set {year:y, month:m, day:d, hours:h, minutes:min} to theMessage's date sent
set timeStamp to ("" & y & "-" & my pad(m as integer) & "-" & my pad(d) & "-" & my pad(h) & "-" & my pad(min))
-- Save the attachment
repeat with theAttachment in theMessage's mail attachments
set originalName to name of theAttachment
set savePath to attachmentsFolder & ":" & subFolder & ":" & timeStamp & " " & originalName
try
save theAttachment in savePath
end try
end repeat
end repeat
end tell
end perform_mail_action
-- Adds leading zeros to date components
on pad(n)
return text -2 thru -1 of ("00" & n)
end pad
My rule for running this script is as shown in the screenshot attached. The example.com address is a dummy address (Duh!)
No matter what I do, I cannot get this script to work. It doesn't work when the message first arrives in my inbox nor does it work if I select the message and select "Apply Rules". I have checked the spelling of the default saving folder name agains the name in the script. It is all correct. When I compile the script, there are NO errors.
Can someone PLEASE help me to get this to work. It would be IMMENSELY appreciated.