Help with code to bounce emails
I am trying to set up Apple Mail to bounce emails that I don't want and send the error message back to sender.
This seems devilishly hard to do, and I found instructions online but they're not working. Thought maybe someone in the community would have an idea of what is not working about the code, here.
PASTED IN INSTRUCTIONS
If you want to get your Bounce back, whatever the reason, here’s how to do it – step by step:-
- Run the Automator program, located in your Applications folder.
- Click ‘New Document’ button.
- Select ‘Quick Action’ as document type then click the ‘Choose’ button. You’ll now have a window that you can drag and drop various actions in to.
- In left most pane, Select ‘Mail’, then in pane to right, select ‘Get Selected Mail Items’ (see screenshot 1).
- In the main editor’s ‘Workflow receives’ drop down menu at the top, select ‘no input’.
- Drag ‘Get Selected Mail Items’ Items to the right into the main editor window.
- In left most pane Select ‘Utilities’, then in pane to right select ‘Run AppleScript’ then drag ‘Run AppleScript’ into the editor window (see screenshot 2).
- Copy and paste the AppleScript code below into the ‘Run AppleScript’ editor (replacing all the default code) and save the workflow with a meaningful name such as, ‘Bounce Email’ (see screenshot 3).
The code to copy and paste:
on run {input, parameters}
tell application "Mail"
repeat with msg in input
bounce msg
delete msg
end repeat
end tell
end run
When you’re in Apple Mail, you can now select a message that you want to Bounce i.e. from the ‘Mail’ menu, select ‘Services’ and then ‘Bounce Email’. The simplest way to check this out is to send yourself an email and to bounce it back to yourself.