Last active
September 28, 2015 00:38
-
-
Save matthewmcvickar/1357611 to your computer and use it in GitHub Desktop.
Set Mail.app Message Sender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Set Mail.app Sender | |
By Matthew McVickar | |
Description: | |
Mail.app's AppleScript library does not allow access to the properties | |
of the outgoing message object. The only way to change those properties | |
is by GUI scripting. This particular script changes the sender of the | |
message. If you have, for example, personal and work email addresses | |
between you switch often, this script is essential. | |
Instructions: | |
Change the email addresses below to the ones you want to cycle through, | |
including their placement in the dropdown (e.g. if they're listed third, | |
their index is 3). | |
Limitations: | |
At the moment, this script only supports cycling through two senders at | |
once, though I imagine it could be expanded to multiple senders easily. | |
*) | |
set email_address_1 to "[email protected]" | |
set email_address_1_index to 1 | |
set email_address_2 to "[email protected]" | |
set email_address_2_index to 3 | |
tell application "System Events" | |
tell process "Mail" | |
-- Click on the 'Sender' the dropdown. | |
click pop up button 2 of window 1 | |
-- Change the sender depending on what is already selected. | |
if value of pop up button 2 of window 1 contains email_address_2 then | |
click menu item email_address_1_index of menu 1 of pop up button 2 of window 1 | |
else if value of pop up button 2 of window 1 contains email_address_1 then | |
click menu item email_address_2_index of menu 1 of pop up button 2 of window 1 | |
else | |
click menu item 1 of menu 1 of pop up button 2 of window 1 | |
end if | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment