Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can an AppleScript have Mail Auto Close Original Message After Reply / Forward?

I've experienced a problem that a bunch of other people are having. A longer description is here: Way for Mail to Auto Close Original Message After Reply /


Basically, if you double-click and open an email, then reply to it, Mail now no longer has an option to auto-close the original email. This seems like something that could easily be solved with a simple AppleScript, but I don't know how to do it.


Any help would be greatly appreciated.


Thanks.

Mail-OTHER, OS X Yosemite (10.10.3)

Posted on Jun 30, 2015 9:33 AM

Reply
5 replies

Jun 30, 2015 10:46 AM in response to tacologic

This seems like something that could easily be solved with a simple AppleScript


Unfortunately you are wrong. There is no way for AppleScript to react to some arbitrary event such as sending an email. It has no idea whether the outgoing message was related to an existing open email.


The only way you could do this is to invert the process - basically have AppleScript initiate the message reply (via some keystroke or other), so that it knows the full context of the message in question.

Jun 30, 2015 6:17 PM in response to tacologic

There is no window or outgoing message trigger that I know of. The only workaround that I can think of to execute automatically is really clunky. If you Cc yourself, the incoming Email will trigger an action rule to run an AppleScript. The speed at which the original message window closes depends on how soon you receive the Email. With small messages this can happen almost instantly; larger messages which include attachments will take longer, sometimes much longer.

The script assumes you are replying to a message from your Inbox. If replying from another mailbox substitute the name, for example: "— Work". The script will close every Mail window whose name property contains "— Inbox". It won't close the Message Viewer whose name property contains the word "Inbox" when the Inbox mailbox is selected, nor a New Message window, nor any window from another mailbox.

User uploaded fileUser uploaded fileUser uploaded file

If you don't want to close every window whose name contains "— Inbox", you can reference a window by descriptive index or position relative to other windows:

close {the first window whose name contains "— Inbox"}

close {the 2nd window whose name contains "— Inbox"}

close {the front window whose name contains "— Inbox"}

close {the last window whose name contains "— Inbox"}

close {the window before the last window whose name contains "— Inbox"}

Save your script to /Users/<username>/Library/Application Scripts/com.apple.mail

tell application "Mail" try close {every window whose name contains "— Inbox"} end try end tell

To set up a Mail rule, from Mail's menu bar navigate to Mail > Preferences > Rules and click the "Add Rule" button. You can move the Email you Cc yourself to the trash by adding an action to your rule, unless you do send Email to yourself at other times. If you don't mind Emails you Cc yourself remaining in your Inbox, no need to move it. If you don't want Emails you Cc yourself in your Inbox, move it to another mailbox by adding an action to your rule. To Cc yourself automatically, from Mail's menu bar navigate to Mail > Preferences > Composing and select "Automatically Cc: myself".

User uploaded file

Mail (Yosemite): Use rules to manage your inbox

Mail (Yosemite): Use scripts as rule actions

Can an AppleScript have Mail Auto Close Original Message After Reply / Forward?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.