The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Help? Send flagged messages to Omnifocus automatically, changing title/context based on from/subject Thread Tools Search this Thread Display Modes
Hello. Been working on a project for a while and can't figure out a way to do this reliably. I've been using this Applescript (won't let me post URLs: hanchorllc.com/2011/12/11/omnifocus-task-auto-import-via-ios-mail-flags/) to send flagged messages to Omnifocus, but the implementation is a little dumb. I'd like to be able to change the title and context of a task based on who's from or subject. I've sort of brute-forced this by making different Applescripts for each rule I want and making it run when getting the specified email.

I'll explain the use, I feel I'm being obtuse: I live on a college campus and use email for a ton of notifications (eg. package received at campus mail room, book ready to be picked up from library). I have my Macbook constantly running in my dorm, collecting these emails and ready to send them to Omnifocus, so for example I can look at the iPhone version of Omnifocus and see I should stop by the mail room to get my package while I'm out. Another use is Kickstarter "Response needed!" emails: I'd like to catch these and throw them into my Internet context.

What I've done is make a bunch of mail rules that automatically flag an email from, for example, the campus mail room, then run the appropriately edited above Applescript which throws an Omnifocus task with the "Mail Room" (or "Library," or "Internet") context and "Pick up package from mail room." (or "Pick up book from library," or "Respond to Kickstarter." title, with the body of the email in the notes section. This would work fine, except when I inevitably receive a mail room and a library email and the rule runs and there are either unnecessary or incorrect duplicate tasks made.

Is there a way to get the subject/from part of a flagged email in Applescript then change the title or context of the task accordingly, and do so for each flagged email? I can't figure it out.

I'm sure this could be applied to anyone who gets similar high priority emails. Thanks for any help, and if I'm at all unclear or obtuse please let me know. I'll clarify. Really looking for a solution.

Attached is an example of one of the Mail rules I use.
Attached Thumbnails
Click image for larger version

Name:	Snapshot 10:15:12 6:05 PM.png
Views:	450
Size:	60.2 KB
ID:	2600  
 
Spent some time figuring it out myself, here's how for those that find this thread.

First make a mail rule that collects the messages you want it to collect. I've attached a screenshot of one of mine.

The "Amazon Order Shipped" script is this:

Code:
using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			set theMailCount to (count of theMessages)
			
			repeat with counter from 1 to theMailCount
				set msg to item counter of theMessages
				set theAttachmentCount to (count of mail attachments of msg)
				set _title to subject of msg
				set _sender to sender of msg
				set _notes to the content of msg
				
				set _combined to "message://%3c" & msg's message id & "%3e" & return & return & _title & return & return & _notes
				
				tell application "OmniFocus"
					tell default document
						set theContext to (first flattened context where its name = "Computer")
						set newTask to make new inbox task with properties {name:"Add tracking number to package tracking application.", note:_combined, flagged:true, context:theContext}
					end tell
				end tell
				
			end repeat
			
		end tell
	end perform mail action with messages
end using terms from
This can be really, really easily modified for almost any use that involves collecting emails. I've made multiple Applescripts for each use of mine, changing appropriately this part:

Code:
						set theContext to (first flattened context where its name = "Computer")
set newTask to make new inbox task with properties {name:"Add tracking number to package tracking application.", note:_combined, flagged:true, context:theContext}
To whatever context and title I want.

Pretty simple stuff, but hope this helps someone.
Attached Thumbnails
Click image for larger version

Name:	Snapshot 10:15:12 10:19 PM.png
Views:	434
Size:	49.8 KB
ID:	2601  
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Flagged Messages wesley.elder OmniFocus 1 for Mac 5 2014-05-02 09:17 PM
Location Reminders - task-based rather than Context-based? dmcomeau OmniFocus for iPhone 17 2012-02-14 07:10 AM
Send MULTIPLE MAC mail messages at one to Omnifocus groogan OmniFocus 1 for Mac 1 2010-04-27 02:04 AM
Automatically send all email messages to Omnifocus inbox mojaverat OmniFocus 1 for Mac 6 2010-04-23 10:10 PM
Changing Send to OmniFocus inbox behavior ptorngaard OmniFocus Extras 4 2010-02-11 03:05 PM


All times are GMT -8. The time now is 07:54 AM.


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