AppleScripting Email > Developing a Quoted Reply Service
A reader recently wrote to me with a problem. Apparently, Microsoft Outlook no longer contains the ability to create quote level chunks of text when replying to messages in plain text format. Why this functionality was removed, I can't say. But, with a little help from AppleScript and Automator, I was able to help the reader to add this functionality back via a Service. Better yet, the Service can be set up to work in any email client, or even system-wide in any app. Here's how you can do it...
Building the Service
1. Launch Automator (in /Applications) and create a new Service workflow.
Creating a Service workflow in Automator
2. Configure the workflow (at the top) to process selected text in any application, or your favorite email client, such as Mail or Outlook. Then, select the "Output replaces selected text" checkbox.
In this screenshot, the Service is set to appear only in the Outlook app.
3. Find and add the Run AppleScript action to the workflow. It should link up with the header, indicating that it receives text as input. Enter the following script into the action.
Note: If you get stuck, you can download the completed script and workflow here.
Example of the completed workflow
4. The script above is set to limit lines to a maximum of 42 characters. If you want longer lines, go ahead and adjust this in the script. Just set the theMaxLineLength variable to the desired length. Also, note that this is a guideline. The script tries not to break words in the middle. So, if an extra long word is encountered, you may still have lines longer than the maximum length.
5. Save the workflow as Email > Quote Selected Text. Automator puts it where it needs to go.
Saving the Service workflow
Using the Service
Now, anytime you're in your email app and want to create quoted text in a plain text message, just select the desired text. Right-click it (or Option+Click it) to display the contextual menu. Then, select Services > Email > Quote Selected Text. Again, this is intended for plain text messages. It will probably generate inconsistent results with HTML formatted text.
Triggering the workflow from the Services contextual menu in Outlook to process selected text in a message
If you don't see the Services menu in the contextual menu, then whatever app you're using may not support contextual Services. In this case, try triggering the workflow from the App > Services menu instead.
Triggering the workflow from the Application > Services menu
If all goes well, your selected text is passed to the Service workflow, and the processed quoted text is inserted. Happy Scripting!
A message containing processed text
Subscribe to Newsletter
Software Updatesmore updates
- Apple Remote Desktop updated with Yosemite support
- OS X Yosemite 10.10.2, iOS 8.1.3 updates now available
- Sports Illustrated 120 SPORTS channel comes to Apple TV
- Logic Pro X update brings AirDrop support, new effects, tools, and more
- Parallels Access 2.5 released, adds file manager, computer-to-computer remote access
- The Google Translate iOS app is about to get a lot smarter