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?


All times are GMT -8. The time now is 05:17 AM.

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