I’d like to write an AppleScript to set the sender of the current outgoing message in Apple’s Mail.app.
I’ve tried this:
tell application "Mail" to set sender of front outgoing message to "<my email address>"
but I get the error message error "Mail got an error: Can’t set sender of item to any." number -10006 from sender of item to any which doesn’t make sense to me.
When I try to interrogate the front outgoing message as follows:
tell application "Mail" to get properties of front outgoing message
I get {class:item} in return, instead of an “outgoing message” object like I’d expect.
Any ideas?
Unfortunately, you cannot get or set the properties of the
outgoing messageobject of Mail with Applescript.Instead, you can accomplish this with GUI scripting, a workaround that directly manipulates window elements.
This code should work for you:
Change the
menu item 6on the fourth line to whichever number in the list your desired sender is (e.g., if the sender you want to change to with this script is the fourth one listed, changemenu item 6tomenu item 4).Update: If you’re curious, since this answer is over two years old: as of 2014-04-26, getting/setting the properties of
outgoing messages is still impossible and this workaround still works in OS X 10.9 Mavericks.