Automator workflow of the month: Extract essential email data
It’s not uncommon to receive email messages jammed with important links and addresses. If you often wish you could save these bits of information without having to archive (and search through) the messages that contain them, you’ll be happy to hear that Lion’s version of Automator makes it possible.
For several years now, OS X has included subtle, but useful, “data detectors.” Hover your cursor over a date or email address in Apple’s Mail, for example, and a little triangle appears. Click this to choose from a number of relevant options: say, to add a date to your iCal calendar or an address to your Address Book list. Among Automator’s new features under Lion is the ability to extract data-detector information from compatible documents. The following one-step workflow harnesses this ability to extract email addresses from a Mail message and place that information in a new TextEdit document. Note that this workflow works only in Lion, not in earlier versions of the Mac OS.
Create the workflow
Launch Automator (/Applications) and in the template sheet that appears, choose Service. Select the Text entry in the Library pane and then drag the New TextEdit Document action from the Actions pane to the workflow area. Configure the top of the window to read Service Receives Selected Email Addresses in Mail. From the Input Is pop-up menu select Only Email Addresses. Save your workflow with a name such as Extract Email Address.
Launch Mail and select the contents of an email message that you’d like to extract embedded email addresses from. From the Mail menu choose Services and then the Extract Email Address service you created. Any email addresses embedded in the body of the message (but not any addresses in the header) will be copied and then pasted into a TextEdit document.
The Service Receives Selected pop-up menu includes not only the option to extract email addresses but also a host of other items including URLs, dates, physical addresses, and phone numbers, so you can modify this workflow to collect other kinds of data too. For example, if you want to suck all the links out of an email message, choose URLs. Additionally, there’s no reason for you to limit this service to just Mail. If you configure the top of the window to read Service Receives Selected Email Addresses in Any Application, you can invoke it wherever data detectors can be found.
If you find this workflow useful and intend to employ it on a regular basis, assign a keyboard shortcut to it. Do this by launching the Keyboard system preference, selecting the Keyboard Shortcuts tab, choosing Services in the window’s first pane, and then selecting your Extract Email Address workflow in the pane to the right. Click to the far right of the workflow entry and in the field that appears, enter a keyboard shortcut.
Updated 7/26/11 9:00 AM to provide more direct workflow.