TUAW Post > AppleScripting Email > Developing a Quoted Reply Service

outlook_autoA 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 systemwide in any app. Here's how you can do it...

[Read more on TUAW...]

TUAW Post > AppleScripting Mail > Announce New Emails By Voice

mail_scriptYou're in the kitchen cooking dinner, or sitting down watching TV, or exercising. Ding! You have a new email. Quickly, run to your Mac to see who it's from. Meh, spam. Ding! Meh, a message from your boss. Ding! Meh. Sure would be nice if Mail could announce who's emailing you. That way, you could just listen for ones you care about. Well, with the help of AppleScript and Mail rules, you can set this up on your own. Think of it as an audible caller ID, but for email.

[Read more on TUAW...]

Macworld > Ask the Script Doctor: Solving Mail problems

I'm very happy to announce my new scripting column for Macworld, Ask the Script Doctor.  The first one focuses on answering reader questions about AppleScripting Mail.

[Read more at Macworld.com, subscribe to the print edition, or get Macworld on your iPad...]

Do you have a scripting problem or a question for the Script Doctor? Send it to scriptdoctor@macworld.com.

 

Mail to FileMaker Importer 2.2.4 Released

Updated to fix an issue when opening a remote FileMaker 12 database. [More info or download a demo...]

Mac Productivity: Quick Scripts and Workflows – Archiving Selected Mail Messages

Keeping up with email often seems like a losing battle. One thing that can help is reducing the number of messages in your inbox. Filing messages into individual mailboxes can be time consuming and inefficient. While dumping them all into a single mailbox may seem like a way to create a big mess, Mail’s search capabilities actually make it quite easy to locate specific messages.

Taking a lesson from Gmail’s All Mail feature, Mail in Lion includes a new option for archiving messages. Just select a message, choose Message > Archive from the menu bar, and the message is moved into an Archive mailbox, which Mail will create if it doesn’t exist. This feature gives Mail users a quick and easy way to file messages, getting them out of that bloated inbox.

I’d love to use Mail’s built-in Archive feature. However, it only archives to the mail server (for IMAP accounts, anyway, which is what I have). I keep my email archive locally. So, I used a combination of AppleScript and Automator to create my own Archive feature. Here’s how... [Read more on the Peachpit blog...]

AppleScripts for Marking Messages as Read in Mac Mail

At the request of MacSparky, I've put together a few AppleScripts for Mac Mail users, to mark messages as read...

Script 1: Mail • Mark All Inbox Messages Read

tell application "Mail"
     set read status of every message of inbox to true
end tell

Script 2: Mail • Mark All Messages Read

display alert "Please note!" message "This script may take a while if you have a ton of mailboxes. Do you want to continue?" buttons {"Cancel", "Yes"} cancel button "Cancel"

with timeout of  600 seconds
     tell application "Mail"
          set read status of every message of inbox where its read status = false to true
          set read status of every message of every ¬
               mailbox where its read status = false to true
          set read status of every message of every mailbox ¬
               of every account where its read status = false to true
     end tell
end timeout

Script 3: Mail • Mark Selected Mailbox Messages Read

display alert "Please note!" message "This script may take a while if you have a lot of mailboxes selected. Do you want to continue?" buttons {"Cancel", "Yes"} cancel button "Cancel"

set processSubMailboxes to (button returned of (display alert "Would you like to scan all submailboxes too?" message "Again, if you have a lot of selected mailboxes and submailboxes, this may take a while." buttons {"Yes", "No"})) = "Yes"

tell application "Mail"
     tell front message viewer
          set theSelectedMailboxes to selected mailboxes
          repeat with a from 1 to length of theSelectedMailboxes
               set theCurrentMailbox to item a of theSelectedMailboxes
               processMailbox(theCurrentMailbox, processSubMailboxes) of me
          end repeat
     end tell
end tell

on processMailbox(theMailbox, processSubMailboxes)
     tell application "Mail"
          if processSubMailboxes = true then
               set theSubMailboxes to every mailbox of theMailbox
               repeat with a from 1 to length of theSubMailboxes
                    set theCurrentSubMailbox to item a of theSubMailboxes
                    processMailbox(theCurrentSubMailbox, processSubMailboxes) of me
               end repeat
          end if
          set read status of every message of theMailbox to true
     end tell
end processMailbox

Usage

You can download these scripts here.

You can quickly and easily run them from the system-wide AppleScript menu.  This menu is not enabled by default.  To enable it and install the scripts...

  1. Launch AppleScript Editor in /Applications/Utilities
  2. Select AppleScript Editor > Preferences from the menu bar
  3. Under General, click the Show Script Menu in the Menu Bar checkbox
  4. Bring Mail to the front
  5. From the script menu, choose Open Scripts Folder > Open Mail Scripts Folder
  6. Copy the scripts into the folder.  They will now be available from the script menu when you're working in Mail

Enjoy!

-Ben

What not to do in Mac Mail

Here's a handy data loss prevention tip.  With a Mail message selected, do not press either of the secret undocumented keyboard shortcuts Option+Control+H or  Command+Option+Control+H.  That is, unless you want your selected message irretrievably deleted.  Not moved to the trash.  Deleted.  Permanently.

Tested in Mac OS X 10.7.3. Bug report filed.

Note: If you're backing your Mac up with Time Machine, as you should be, then you may be able to restore the vaporized message.

Developer Tip > Saving Mail Attachments via AppleScript Fixed in Lion 10.7.2

If you use AppleScripts that interact with Mail in Mac OS X (such as Mail to FileMaker Importer), you may have noticed that when Lion was introduced, the ability to save attachments through scripting no longer worked.  This issue affected AppleScripts, as well as Automator workflows (Apple's own Get Attachments from Mail Messages Automator action was broken too).  Well, I'm pleased to say that this issue has been resolved in Mac OS X 10.7.2.  AppleScripts can now save Mail attachments again.

If you'd like to learn more about AppleScripting Mail, check out my MacTech column... Introduction to Scripting Mail.

Attention Outlook Users: Saving attachments via AppleScript did not work in Outlook either until a recent Office update.  If your Outlook scripts are failing when attempting to save attachments, make sure you update your Office 2011 installation to the latest version.  While I don't have an article available at this time for scripting Outlook, you can learn about scripting Entourage in my MacTech column... Introduction to Scripting Microsoft Entourage.  The AppleScript terminology hasn't changed too much between Entourage and Outlook, so some of it may still apply.

Peachpit Article > Running Automator Workflows From Mail Rules

06.09.09 - Running Automator Workflows From Mail Rules.

If you're an Automator user, you're probably aware that it's possible to save an Automator workflow in a variety of ways. At the basic level, a workflow can be saved as a workflow file that can be opened in Automator, or as an application that can be launched and run like any other application. At a slightly more advanced level, Automator workflows can be saved as plug-ins for certain applications and processes, including the Mac OS X Finder, iCal, Image Capture, PDF printing services, and more.

Presently, Automator doesn't offer a way to save workflows as plug-ins for Mail, to be run when new email messages arrive. However, you can add this ability yourself. To do so, you'll need the help of a Mail rule, some AppleScript, and an Automator workflow. Let's walk through the process. [Read more at Peachpit.com...]

MacTech AppleScript Essentials Column > Introduction to Scripting Mail

September, 2005 - Introduction to Scripting Mail.

Email automation is usually popular among AppleScript developers using Mac OS X. By writing scripts to perform email-related processes, developers can automate processes such as sending batches of recipient-customized messages, archiving emails in text format or in a database, emailing status reports to administrators, and much more.

In this month's article, we will discuss using AppleScript to automate aspects of the Mail application, which comes pre-installed with OS X. If you don't use the Mail application, then you may want to explore some of the many other scriptable email clients and tools that are available for the Mac. Some of these will be mentioned later in this article. [Read more at MacTech.com...]