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

 
Can't send emails to specific project in OF Thread Tools Search this Thread Display Modes
I've copied the following script and adapted it a bit. (I'm not sure where I copied it from since I've either deleted it or there was no contact information in the script.)

It was working fine before upgrading to Mountain Lion but now instead of creating a task in the folder "Waiting For..." with the context "Waiting For..." it creates a task in the Inbox. The task does have the correct start date (current date + 2 days).

Any help would be great.

Thanks


on run

tell application "Mail"


set _msgs_to_capture to selection

repeat with eachMessage in _msgs_to_capture
set theStart to (current date) + (2 * days)
set theDue to missing value
set theOmniTask to missing value

set theTitle to the subject of eachMessage
set theNotes to the content of eachMessage
set theContextName to "Waiting For..."
set theProjectName to "Waiting For..."

set theCombinedBody to "message://%3c" & message id of eachMessage & "%3e" & return & return & theNotes

tell application "OmniFocus"
tell default document
set newTaskProps to {name:theTitle}
set theContext to context theContextName
set theProject to project theProjectName
set newTaskProps to newTaskProps & {containing project:theProject}
set newTaskProps to newTaskProps & {context:theContext}
if theStart is not missing value then set newTaskProps to newTaskProps & {start date:theStart}
if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
if theCombinedBody is not missing value then set newTaskProps to newTaskProps & {note:theCombinedBody}

tell theProject
set newTask to make new task with properties newTaskProps
end tell

end tell
end tell


end repeat

end tell

end run
 
My AppleScript's a little fuzzy, so I'm not seeing the problem right away.
However, here's what I would do to debug it:

Add this line:
Code:
display dialog name of theProject as string
Right before:
Code:
tell theProject
This will let you know if you've actually found the project you mean to find or not.

Staring harder, maybe change
Code:
set theProject to project theProjectName
to
Code:
set theProject to project named theProjectName
 
I've made the two suggested changes:

Code:
set theProject to project named theProjectName
Code:
display dialog name of theProject as string
I added the following line after "tell theProject"

Code:
set theProject to project named theProjectName
I get the following error:
OmniFocus got an error: Can’t get project "Waiting For..." of project id "f3xRiry3AmI" of document id "dmjA-CUMhkW".

It appears it can't find the project but the project "Waiting For.." exists in OmniFocus and is active and not nested.

Thanks
 
One approach to a GetProject function might look like this:

Code:
tell application id "OFOC"
	set oDoc to default document
	set oProj to my GetProject(oDoc, "Integrate top-level themes")
end tell

on GetProject(oDoc, strName)
	using terms from application "OmniFocus"
		tell oDoc
			set lstProj to flattened projects where name begins with strName
			if length of lstProj < 1 then return missing value
			return item 1 of lstProj
		end tell
	end using terms from
end GetProject
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Turning emails into actions: send-to-omnifocus@omnigroup.com Brian OmniFocus for iPad 27 2012-12-03 03:44 PM
send-to-omnifocus emails not working? android phone alternatives? travisp OmniFocus 1 for Mac 1 2012-06-09 08:55 PM
Handling Project Support emails and other material? mmurray OmniFocus 1 for Mac 7 2011-09-13 05:50 PM
Turning Bugzilla emails into actions in the correct project kstrauser OmniFocus 1 for Mac 2 2010-12-04 07:57 AM
How do I move a project to a specific folder? rloconne OmniFocus Extras 6 2008-01-24 04:13 PM


All times are GMT -8. The time now is 12:39 PM.


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