The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Using ReQall.com to get tasks into OmniFocus (http://forums.omnigroup.com/showthread.php?t=8735)

txaggie90 2008-07-15 05:57 PM

Using ReQall.com to get tasks into OmniFocus
 
I have been playing around with the iPhone version and also the desktop version trying to figure things out. I see where OmniFocus can add tasks based on specially formatted emails.

I'm also testing ReQall. It is an iPhone app that will convert a voice command to text. I recall seeing where it can send emails with new tasks, but haven't researched how customizable the emails are.

My question is has anyone tried to link these two programs together? It would be nice to send a quick voice command to add a task to OmniFocus.

willray 2008-07-18 11:55 AM

I hacked together something that's working for me, based on
a couple other people's mail-into-ical scripts that have been
hashed around on the 'net for several years. Embarassingly I've
forgotten the original sources for major portions of the code,
so I can't give credit where it's due - only can say that most of
the bugs and kludges are mine.

[url]http://idisk.mac.com/willray-Public?view=web[/url]

Download the mAil_tWo_iCal.scpt file.

You'll need to edit it internally to put it in an appropriate
calendar.

I have a "Penciled" calendar where I put incoming
tasks and possibly-scheduled items - OmniFocus is configured
to sync that with a "Penciled" context, which is used for nothing
except capturing that calendar. I also have OF configured to leave
tasks in the inbox until they've had both a context and a project
assigned, so things that land in Penciled, also show up in the
inbox. Requires the discipline to change the context when you
process your inbox, but that doesn't so far seem an impediment.

Mail has a rule set up to run this AppleScript whenever a message
with a subject starting with "Task : " appears in the inbox.

It has a second rule set up to move messages starting with "Task : "
into an archived tasks box.

These are set up as independent rules, because Mail, for reasons
impenetrable to me, has started arbitrarily reordering actions
inside rules. The script relies on the message being in the inbox
and being unread, and at least on my machine, when I try to add
a "move the message" action to the same rule that invokes the
AppleScript, Mail rearranges the actions and puts the "move" action
before the AppleScript action. (I'm pretty sure this is a new bug
in Leopard - rules didn't rearrange themselves previously, to the
best of my recollection).

Hmm - what else..

Ah, the script fills in the to-do task URL with the Mail message ID,
but Omnifocus re-writes that to be a URL to point to the OF task,
once it's synced it into the OF database. To make sure that you
can still get back to the Mail task, the script also writes the text of
the URL into the task note body - sometimes this appears clickable,
sometimes you need to highlight it and "go to URL". Either way,
it's an ugly URL, but I haven't taken the time to figure out how
to do a clip-o-tron-like URL-text redisplay, or rewrap the message
body in RTF, so that it shows up prettily in the note.

Oh, and the script's a bit cheeky, and still contains various debugging
bits that should be excised, and inelegancies that should be polished.
I of course am not making any warranties as to its utility, and don't
have that much time for maintenance, but I'll do my best to help
with setting it up, if there are questions. I'd also love to see
improvements, if anyone feels like banging on more functionality.

Good luck,
Will Ray

txaggie90 2008-07-19 02:36 PM

Thanks for writing that. I'll check it out. If I make any changes, do you mind if I repost it in the forums?

Lucas 2008-07-20 11:28 AM

I use Jott - which seems like a similar idea - by setting up at Jott recipient to the "email+omnifocus@whatever.com" email address, which is then auto-imported into the mailbox by the mail rule.

dbyler 2008-08-04 08:34 AM

reQall > OmniFocus script
 
I modified the Jott » OmniFocus script (which, in turn, was modified from some of Curt Clifton's work) to work with reQall mail. Should handle any of the reQall types.

That said, I'll probably keep using Jott (dial-in, not iPhone app) because it's been faster and more reliable for me.

Script here:

[CODE](* Derived by dbyler from "Jott to OmniFocus" to work with reQall mail. See below. *)

-- Derived from work that is Copyright © 2007, Curtis Clifton All rights reserved.
-- Modified to work specifically with Jott messages.

-- If true, then the sender of the message is included in the action's description.

-- From http://forums.omnigroup.com/showthread.php?t=7651

property includeSender : true

property messageSender : "reQall"

on run
tell application "Mail"
set selectedMessages to selection
if ((count of selectedMessages) ≠ 1) then
display alert "Please select a message to be linked to the new action" message "This script creates a new OmniFocus action that links back to a selected message." buttons {"OK"} default button "OK" giving up after 20
return
end if
my process_message(item 1 of selectedMessages)
end tell
end run

using terms from application "Mail"
on perform mail action with messages theMessages
try
set theMessageCount to count of theMessages
repeat with theMessageIndex from 1 to theMessageCount
my process_message(item theMessageIndex of theMessages)
end repeat
on error m number n
tell application "OmniFocus"
log "Exception in Mail action: (" & n & ") " & m
end tell
end try
end perform mail action with messages
end using terms from

on process_message(theMessage)
tell application "Mail"
set theContent to source of theMessage
set theDate to date sent of theMessage
set messageId to message id of theMessage
end tell

tell application "OmniFocus"
set messageStart to (offset of "added to reqall" in theContent) + 17
set messageEnd to (offset of "Invite your friends" in theContent) - 76
set taskName to rich text messageStart through messageEnd of theContent
if (includeSender) then
set taskName to taskName & "—" & messageSender
end if
set theDoc to first document
tell theDoc
set propRecord to {name:taskName}
set theTask to make new inbox task with properties propRecord
end tell
tell theTask
set start date to theDate
set note to return & return
tell note
set theURL to "message://<" & messageId & ">"
set linkText to theURL
insert linkText at before first character
set value of attribute "link" of style of paragraph 1 to theURL
end tell
end tell
end tell
end process_message
[/CODE]

Lucas 2008-09-14 09:02 PM

I made two small modifications to dblyler's script to work better:
1: I changed the +17 to +21 to cut a couple more letters off the front
2: I changed "first document" to "default document", which makes it work when the OF window is closed.

bigtoe 2008-12-06 01:16 PM

Easier method
 
See here: [url]http://forums.omnigroup.com/showthread.php?p=52127#post52127[/url]

whshep 2009-04-18 02:26 PM

Does anyone know how to modify the dbyler script to automatically set a context on all incoming items?

Lucas 2009-04-25 04:44 PM

[QUOTE=whshep;58720]Does anyone know how to modify the dbyler script to automatically set a context on all incoming items?[/QUOTE]

This is an example of setting context for new items in script:

tell application "OmniFocus"
set theName to "Hello"
set theContent to "Some content"
set theContext to context "Home Office" of context "Work" of first document
tell first document
set theTask to make new inbox task with properties {name:theName, note:theContent, context:theContext}

whshep 2009-04-26 05:11 AM

[QUOTE=Lucas;59067]This is an example of setting context for new items in script:

tell application "OmniFocus"
set theName to "Hello"
set theContent to "Some content"
set theContext to context "Home Office" of context "Work" of first document
tell first document
set theTask to make new inbox task with properties {name:theName, note:theContent, context:theContext}[/QUOTE]

Okay, here's the original code, that actually works—it will put items into my OF inbox:

[CODE]tell application "OmniFocus"
set messageStart to (offset of "added to reqall" in theContent) + 18
set messageEnd to (offset of "Edit this item" in theContent) - 2
set taskName to rich text messageStart through messageEnd of theContent
if (includeSender) then
set taskName to taskName & "—" & messageSender
end if
set theDoc to default document
tell theDoc
set propRecord to {name:taskName}
set theTask to make new inbox task with properties propRecord
end tell
tell theTask
set start date to theDate
set due date to theDate
set note to return & return
tell note
set theURL to "message://<" & messageId & ">"
set linkText to theURL
insert linkText at before first character
set value of attribute "link" of style of paragraph 1 to theURL
end tell
end tell[/CODE]

Now if I understand you correctly, to get the items automatically assigned to a context "ReQall," I would do something like this:

[CODE]tell application "OmniFocus"
set messageStart to (offset of "added to reqall" in theContent) + 18
set messageEnd to (offset of "Edit this item" in theContent) - 2
set taskName to rich text messageStart through messageEnd of theContent
[I][B]set taskContext to "ReQall"[/B][/I]
if (includeSender) then
set taskName to taskName & "—" & messageSender
end if
set theDoc to default document
tell theDoc
set propRecord to {name:taskName, [I][B]context:taskContext[/B][/I]}
set theTask to make new inbox task with properties propRecord
end tell
tell theTask
set start date to theDate
set due date to theDate
set note to return & return
tell note
set theURL to "message://<" & messageId & ">"
set linkText to theURL
insert linkText at before first character
set value of attribute "link" of style of paragraph 1 to theURL
end tell
end tell[/CODE]

This doesn't work—it doesn't seem to do anything.

And in your example, I don't understand the line:

set theContext to context "Home Office" of context "Work" of first document

That would seem to set the context to a "Home Office" subset of "Work," which I don't have (also, the macro is working with default document).

Any help would be appreciated!


All times are GMT -8. The time now is 04:16 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.