The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus 1 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=38)
-   -   Send Mail message (with link) to OF Inbox (http://forums.omnigroup.com/showthread.php?t=3783)

zooids 2007-06-08 08:55 AM

Send Mail message (with link) to OF Inbox
 
1 Attachment(s)
Thought I'd share this applescript that sends the current selected message in Mail to the Inbox. It includes the context of "Mail" and note with a link back to the message.

Be sure you edit the script to change the context to match yours. Also, you must create the context in OF before the script will function.

Here's what I've found as a best practice in using this:

1. Setup a Mail Act-On Rule to run the script and (optionally) move the message to an "actionable" folder.

2. OF will now have an new inbox task with a name based on the subject, sender, and 1 line summary of the email. In the notes field will be the link back to the Mail message.

3. To easily switch directly to that message, Select All in the note field of the task and press your QuickSilver shortcut to "Command Window with Selection". The default action should be "Open URL". Press return and your Mail message opens in a new window.

Richard Flynn 2007-06-08 09:11 AM

Very cool, thanks for sharing. I've edited the script so that the action created in OmniFocus has no context; that way everything will sit in the Inbox in OmniFocus until I deal with it. (Otherwise, if you click 'Clean Up' and it already has a context assigned, it'll go to that context's lists but not appear in any Project list, which I find very annoying. This way, it'll stay in the Inbox until it's definitely dealt with.)

I also edited it to use em-dashes (—) rather than hyphens (-) between the sections of the action title in OmniFocus. But I know I'm typographically sad.

One thing, though. I don't use Mail Act-On (yet). I copied this script into Mail's scripts folder (~/Library/Scripts/Applications/Mail), but there's no way to activate the script from within Mail itself—it doesn't appear in any of the menus, for example, or on the toolbar. So far I've only run the script from within Script Editor (obviously not a long-term solution, just testing it out). I looked at the DEVONthink scripts in that folder, which do produce items in the 'Message' menu in Mail, but couldn't see anything obvious. Any idea? I'm not an AppleScript maven, I'm afraid.

Thanks very much for this. I was just wondering when we'd see the first OmniFocus AppleScripts!

Richard

Craig 2007-06-08 09:20 AM

Hmm... [CODE]The variable new_Context is not defined.[/CODE]

But if I remove the context business as suggested in the previous post, it works. I have changed the script so that the message text appears in the note field (with the url) instead of in the task title (with the sender and subject).

kmarkley 2007-06-08 10:38 AM

[QUOTE=zooids]3. To easily switch directly to that message, Select All in the note field of the task and press your QuickSilver shortcut to "Command Window with Selection". The default action should be "Open URL". Press return and your Mail message opens in a new window.[/QUOTE]

Thanks for the script.

I can't get the link to work either via QuickSilver or by the right-click context menu. Anyone else have this problem? Something I'm not getting?

steve 2007-06-08 03:35 PM

Zooids,

Thanks for posting this! It is fantastic. I hope someone can make it even better.

For the script to work, this line has to reflect the context you are using in OF:

[QUOTE]set My_Context to "mail"[/QUOTE]

In other words, you would have to have a top-level context called mail.

I have prefer to use "email" so I changed my script to the following:

[QUOTE]tell application "Mail"
set theSelectedMessages to selection
set the selected_message to item 1 ¬
of the theSelectedMessages
set message_id to the message id of the selected_message
set message_url to "message://" & message_id
set message_subj to (subject of selected_message)
set message_sender to (extract name from sender of selected_message)
set message_content to summarize (content of selected_message as string) in 1
end tell

tell application "OmniFocus"
set MyDoc to first document
set My_Context to "email"
set My_Task to message_subj & " - " & message_sender & " - " & message_content

tell MyDoc
try
id of My_Context
on error
set new_Context to first context whose name contains My_Context
end try
make new inbox task with properties {name:My_Task, context:new_Context, note:message_url}
end tell
end tell
[/QUOTE]

Note: you need a top level context called email.

curt.clifton 2007-06-08 05:30 PM

[QUOTE=Richard Flynn]One thing, though. I don't use Mail Act-On (yet). I copied this script into Mail's scripts folder (~/Library/Scripts/Applications/Mail), but there's no way to activate the script from within Mail itself—it doesn't appear in any of the menus, for example, or on the toolbar. So far I've only run the script from within Script Editor (obviously not a long-term solution, just testing it out). I looked at the DEVONthink scripts in that folder, which do produce items in the 'Message' menu in Mail, but couldn't see anything obvious. Any idea? I'm not an AppleScript maven, I'm afraid.[/QUOTE]

You put the script in the right place, but you need to add the Scripts menu to your menu bar. Here's how (from Mail's help):
[QUOTE]To add the Script menu to the menu bar, open AppleScript Utility, located in Applications/AppleScript/. Select the “Show Script Menu in menu bar” checkbox. The menu appears on the right side of the menu bar.[/QUOTE]

curt.clifton 2007-06-08 05:34 PM

[QUOTE=zooids]Thought I'd share this applescript that sends the current selected message in Mail to the Inbox. It includes the context of "Mail" and note with a link back to the message.[/QUOTE]

Does the link back require MailTags? Thanks!

johnrover 2007-06-08 05:41 PM

[QUOTE=Richard Flynn]I looked at the DEVONthink scripts in that folder, which do produce items in the 'Message' menu in Mail, but couldn't see anything obvious. Any idea? I'm not an AppleScript maven, I'm afraid.
Richard[/QUOTE]

The Devonthink applescripts DO show up in the applescript menu. There is a separate Devonthink mail plugin "bundle" that goes in the mail plugins folder that causes that option to show up in the message menu. 2 completely different animals. I would LOVE to see that kind of "plugin" integration.

Also – be aware that placing things in /library/scripts/mail makes things show up system wide in the applescript menu under "mail". Placing things in ~/library/scripts/applications/mail makes things show up in a dynamic applescript menu that [I]only[/I] appears when mail is the active application.

Also – run the "applescript utility" in applications/applescript/applescript utility. There are some OS visibility options in there.

johnrover 2007-06-08 05:58 PM

[QUOTE]set My_Context to "mail"[/QUOTE]

What would the syntax be to set the context to a nexted context, ie: @home –> @onLatop –> email?

johnrover 2007-06-08 06:14 PM

Using quicksilver for the URL bit is very clever. But... It's really cumbersome.

Hey Omni – you are going to add URL support at some point, including "message://", right? Please?

steve 2007-06-08 06:22 PM

[QUOTE]Does the link back require MailTags? Thanks![/QUOTE]

No. Zooids script puts a link in the notes field. It will take you back to the original email wherever you filed it.

steve 2007-06-08 06:27 PM

[QUOTE=johnrover]What would the syntax be to set the context to a nexted context, ie: @home –> @onLatop –> email?[/QUOTE]

I have only been able to get it work for a top level context. I can't wait for someone to take this to the next level.

curt.clifton 2007-06-08 06:42 PM

[QUOTE=steve]No. Zooids script puts a link in the notes field. It will take you back to the original email wherever you filed it.[/QUOTE]

I caught the notes field part of it. I don't have QuickSilver installed, but if I select the "message://..." URL, right-click, and choose Open URL, then nothing happens. I know that MailTags supports the "message://..." scheme. So I guess my question is does the link back require MailTags and/or QuickSilver?

(Not to start a launcher war, but I've been using Butler after becoming frustrated with crashes in QuickSilver plus broken multi-pasteboard support.)

I actually have a script drafted that handles link back with just OmniFocus, with no need to open the notes field. But I need to figure out how to access the selected action using a script--question pending in another thread.

steve 2007-06-08 07:03 PM

Curt,

Perhaps I spoke prematurely. I use both mailtags and quicksilver, but I didn't think that either played a role in zooids script. If I had to guess, I would say that mailtags is involved. After installing it, I noticed "copy url" in the edit pulldown of the mail.app. Zooids, are you out there?

kmarkley 2007-06-08 09:55 PM

For those without mailtags, the following snippet will produce a file URL that works either via QuickSilver or right-click-menu:

[CODE]
set theAccount to account of the mailbox of selected_message
set emlxPath to ((the account directory of theAccount) as text) & "/"
set emlxPath to emlxPath & (name of (mailbox of selected_message) as text) & "."
if (account type of theAccount) as text is "imap" then
set emlxPath to emlxPath & "imap"
end if
set emlxPath to emlxPath & "mbox/Messages/"
set emlxPath to emlxPath & id of the selected_message
set emlxPath to emlxPath & ".emlx"
set message_url to "file://" & emlxPath
[/CODE]

Note: I have one IMAP account and it occasionally creates message files of the form:

123456789.partial.emlx

I have not yet figured out how to test for this and correct the URL.

dcrumbine 2007-07-25 02:17 PM

Using rules to auto-add tasks sent via mail
 
This type of script is fabulous! Although I'm using the one I found for Entourage at [url]http://www.sandro.org/omnifocus/index.php[/url], I wanted to share a useful way for implementing this kind of script that will work with any e-mail program that supports rules which allow you to run applescript.

In Mark Hurst's book "Bit Literacy", he presents some great ideas for e-mailing tasks to a web-based task management program. By using e-mail rules and applescript, you can apply some of those ideas in a stand-alone e-mail client and OmniFocus.

The basic idea is to use e-mail rules to automatically add e-mailed asks to your OF inbox, and optionally then delete the e-mail, all without any user action (because the rules process them automatically). This way, you (or someone else, like your spouse), can send tasks directly to your OF inbox without you having to manually add the tasks from e-mails. You can also BCC yourself when you send someone an e-mail, automatically creating a task to remind yourself to follow up with that person later, etc. - VERY useful.

To do this, I created a dummy e-mail address on my domain, e.g. [email]mytodolist@mydomain.com[/email], and created two rules in Entourage (again, any e-mail client that allows you to create a rule that runs applescript will work). Rule #1: If an e-mail is received with any TO recipient being [email]mytodolist@mydomain.com[/email], run the applescript to add the task to OF then delete the e-mail. Rule #2: If an e-mail is received with any CC or BCC recipient being [email]mytodolist@mydomain.com[/email], run the applescript to add the task to OF but leave the e-mail in your e-mail inbox.

To remove the need to create a dummy e-mail address to support this kind of rule processing in your e-mail client, these scripts could be expanded to strip out something like "todo" at the start of the subject line, so your e-mail program could still identify the e-mail as a task but the OF task wouldn't include "todo" at the start of every task.

Other ideas for expanding on the script would be to also add optional tags to the e-mail subject line to denote context, project, start date, due date. For example, set context by including @... in the subject, project by including ##..., start date by including ((..., due date by including ))... etc. For each of these, the user could use " " to include arguments that have spaces, or no " " for one-word arguments. The script could parse the subject line and set these things whenever they are included, and skip them when they are not, and set the task to the text which appears in the subject before any of these tagging characters are used.

For example...the following e-mail subject line would create a task in your OF inbox called "research applescript for omnifocus" with a context of "home", project "task management", start date of the coming saturday, and due date of 8/1/2007:
[INDENT]todo research applescript for omnifocus @home ##"task management" ((saturday ))8/1/2007[/INDENT]
I hope this is helpful. Thanks to zooids for the Mail applescript and to [email]sandro@sandro.org[/email] for the Entourage script!!!!!!!!!

chummer 2007-07-26 08:03 AM

Is there someone who can tell me why I can't download the attachment? I'm registered and all that, and have flushed my cookies several time to freshen it up, but I continue to get the log in screen when I try to download 'em. Thanks in advance.

rmathes 2007-11-18 05:05 AM

does this script still work with the latest releases of OF? I just installed it and it’s not working.

I use Act On. I put the script into my ~/library/scripts folder and then chose that script to be executed within the rule, but nothing is happening. I created a context called “Mail”, but nada.

curt.clifton 2007-11-20 02:48 PM

zooids script for creating actions from Mail messages was superseded by mine, available [URL="http://www.rose-hulman.edu/~clifton/software.html#OF-Mail"]here[/URL]. Mail Act-On is still in [URL="http://www.indev.ca/MailActOnAndLeopard.html"]beta testing for Leopard[/URL].

rmathes 2007-11-20 05:49 PM

yeah, I'm using act on in leopard and it’s fine.


All times are GMT -8. The time now is 11:43 PM.

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