Adapting Clip-o-Tron to give new task a "Mail" context?

Hello everybody,

I’d like to adapt Mail.applescript in ▸ Contents ▸ PlugIns ▸ BuiltInClippingHandlers.plugin ▸ Contents ▸ Resources so that when I clip a message in Mail, it automatically sets the context to “Mail”. This context exists already in my Omnifocus.

When trying

set context to "Mail"

I always receive an error message when trying to clip in Mail. As my Omnifocus is in German, the error in English should be something like:

„«class FCct»“ can not be set as „"Mail"“. Access not allowed.

The original error in German is:

 „«class FCct»“ kann nicht als „"Mail"“ gesetzt werden. Zugriff nicht erlaubt.

This doesn’t change if I try things like

property MailContext : "Mail"
set context to MailContext

Then the error code is:

„«class FCct»“ can not be set as „MailContext“. Access not allowed.

Has anybody an idea?


Hi! Do you happen to have upgraded to Pro? Custom AppleScripting – including the ability to set a project or context on a task – is a Pro feature, and so in order to accomplish this sort of thing, you’ll need OmniFocus 2 Pro.

That said, it’s important to keep in mind that modifying anything inside the OmniFocus app bundle – including this AppleScript file – is done entirely at your own risk. OmniFocus (and, to a certain extent, OS X) rely on the internals of the application bundle working in certain ways, and changing those inner workings can have unexpected consequences for the rest of the app. At the very least, please be sure your backups are up to date!

Hey Tekl,

yes, I have the Pro version.

And yes, I know it is at my own risk, I keep backup copies of the modified files so that I can always restore the original.

Well, ideal would be something in the preferences of Omnifocus/Clip-o-Tron, where one could decide what information from Mail goes to which field of a new task. But I guess, there are more important tasks to do still, so I thought I help myself :)

Hmm, interesting! If you have Pro, I’m not really sure what might be causing this error. You can always email our support team, or perhaps another AppleScript guru can jump in here?

Hey AppleScript gurus, any idea?

I’m still only a Guru-in-Training ;)
What happens if you run a similar script with the same activities (creating an action, setting its context) directly, rather than through the service?

Well, here my coding capacities are not well enough developed.

If anybody has the will to create a code, it would be perfect if the result is this:

  • Pressing a shortcut in
  • Creating a task in OmniFocus with:
    • Name of task: sender name mouse-marked text in the email - date of the email received
    • OF entry date: date of the email received
    • Context: “Mail”
    • Note: link to original email

This surely could be helpful for others too.


Here is the solution, thanks to Tim, Lizard and Ainsley for supporting!

In Mail.applescript find the following position:

on clipping(CurrentApplicationInfo, ClippingTasks, LocalizedStrings)
     repeat with MyTask in ClippingTasks
         tell MyTask

Put there the following code:

tell application "OmniFocus"
     tell default document
    	set MyContext to first context whose name is "Mail"
    	set context of MyTask to MyContext
     end tell	
end tell