Automator workflow of the month: Easy email replies

Do you routinely receive correspondence that contains a load of email addresses within the body of the message? Say, you're in charge of pulling together a meeting for the company's worldwide accounting department or you receive behind-the-scenes "Get out now while the getting's good!" missives from recently laid off co-workers. You’d dearly love to compose a message to the people associated with these addresses but it’s a bother to copy and paste them into a new message’s To field. If only there was a way to automate the process.

Of course there is. That way is Apple's Automator—specifically an Automator service that uses an AppleScript to work the service’s magic. It shakes out this way:

Compose your workflow

Launch Automator and, from the workflow template chooser, select Service. (Wondering what a service is? See "How to use services in Mac OS X.") Configure the pop-up menus at the top of the workflow to read Service receives selected email addresses in Mail followed by Input is only email addresses.

Select Utilities from the workflow’s Library column and drag the Rdd AppleScript action to the workflow. Delete the text currently in the Run AppleScript action and paste in this text:

on run {input, parameters}
	if the class of input is not list then set input to input as list
	tell application "Mail"
		set newSubject to (get the clipboard)
		set thisMessage to make new outgoing message with properties {subject:"RE:" & newSubject}
		tell thisMessage
			repeat with i from 1 to the count of input
				make new to recipient with properties {address:(item i of input)}
			end repeat
			set visible to true
		end tell
	end tell
	return input
end run

Choose File > Save and name the workflow something like New Message to Selected Addresses. Click Save.

Here you see the complete workflow.

Try it out

Launch Mail and locate a message that contains email addresses you’d like to send a message to. Select some text from within the message that you’d like to serve as the message’s subject and copy it. (For example, "About next week's meeting.")

Now select the email addresses that you’d like to appear in the To field. (You don't have to be exact: if you select other text, the workflow will extract the email addresses from it.)

Finally, Control-click (right-click) on the selected text and from the contextual menu that appears, choose Services > New Message to Selected Addresses. The service will generate a new message with a subject line that bears the copied text and the To field will be filled with the original message’s selected email addresses.

Subscribe to the MacWeek Newsletter

Comments