The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   AppleScript that adds Waiting For emails from Mail.app (delegated tasks) to OmniFocus (http://forums.omnigroup.com/showthread.php?t=12810)

bpwhistler 2009-08-18 06:56 AM

@simplicitybliss...thanks for a great script. This adds significant efficiency to developing follow-ups to emails.

There's a similar script...but goes the other direction (OF -> Mail)...that I just started using. [URL="http://forums.omnigroup.com/showthread.php?t=12953"]http://forums.omnigroup.com/showthread.php?t=12953[/URL] I made a script suggestion regarding adding the email link-back and Growl support you have in your "Waiting for mails to OmniFocus" script.

Perhaps you would be interested in adding these features to this script? :)

I've been playing around with it...but can't seem to make it work.

invictus26 2009-09-20 09:52 PM

Hey, I'm loving the script. I'm just wondering if it could be modified to open the quick entry box instead of going straight to the inbox. Thanks,

-Matt

lolajl 2009-09-21 11:39 AM

I'm hoping the next version of Thunderbird will have services enabled and scriptable so that I can start using OF with it . . .

kaijin 2009-10-11 11:21 AM

The download and instructions link for the script now reroutes to the blog's main page. It looks like simplictyisbliss.com has undergone an overhaul. I hope simplictybliss will update the link, since I heavily use the script and recommend it often.

[I][COLOR="DarkRed"]-- EDIT[/COLOR][/I]: According to an entry, it looks like simplictybliss is in the process of migrating the blog. [I][COLOR="DarkRed"]--[/COLOR][/I]

Omnipper 2010-04-24 12:56 PM

Any progress in this corner? The link to that AppleScript has not resurfaced.

To recap:
If anyone has any solutions for creating a [I]waiting for[/I] OF [I]inbox[/I] item or [I]quick entry[/I] from an outgoing email in mail.app, I'd love to see it. (Using [I]Mail Act-on , [/I]AppleScript, or whatever.. )

Thanks..

Marc

bpwhistler 2010-04-24 07:51 PM

Here is his script...it's working for me and I just copied it from my scripts folder. I got it from simplicityisbliss awhile ago:

[CODE](*
Waiting For Mails to OmniFocus Script
by simplicityisbliss.com, Sven Fechner

Based on an Outbox Rule in Mail.app this script adds specific messages
to the OmniFocus Inbox with the waiting for context

MailTags (www.indev.ca) is required to define the Outbox Rule to only
create tasks for those outgoing emails that are to be tracked in OmniFocus

The script uses Growl for feedback notification if it is installed and running

*)


--!! EDIT THE PROPERTIES BELOW TO MEET YOUR NEEDS !!--

-- Do you want the actualy mail body to be added to the notes section of the OmniFocus task?
-- Set to 'true' is or 'false' if no
property mailBody : true

-- Text between mail recipient (the person you are waiting for to come back) and the email subject
property MidFix : "to follow up re:"

-- Name of your Waiting For context in OmniFocus
property myWFContext : "Waiting For"

-- !! STOP EDITING HERE IF NOT FAMILAR WITH APPLESCRIPT !! --

--Configuration for Growl messages
property GrowlRun : false
property scriptName : "Waiting For Mails to OmniFocus"
property notifySuccess : "Success Notification"
property notifyFail : "Failed Notification"
property titleSuccess : "Waiting For Mail added"
property titleFail : "Waiting For Mail to OmniFocus FAILED"
property txtSuccess : " added to OmniFocus successfully"
property txtFail : " to OmniFocus to add successfully"
property txtIcon : "OmniFocus"

on perform_mail_action(theData)

--Check if Growl is running
tell application "System Events" to set GrowlRun to (count of (every process whose name is "GrowlHelperApp")) > 0

--Setup Growl
if GrowlRun then tell application "GrowlHelperApp" to register as application scriptName all notifications {notifySuccess, notifyFail} default notifications {notifySuccess, notifyFail} icon of application txtIcon

--Get going
tell application "Mail"
set theMessages to |SelectedMessages| of theData --Extract the messages from the rule
repeat with theMessage in theMessages
set theSubject to subject of theMessage
set theRecipient to name of to recipient of theMessage
set theMessageID to urlencode(the message id of theMessage) of me

-- Check if there is one or more recipients
if (count of theRecipient) > 1 then
set theRecipientName to (item 1 of theRecipient & (ASCII character 202) & "and" & (ASCII character 202) & ((count of theRecipient) - 1) as string) & (ASCII character 202) & "more"
else
set theRecipientName to item 1 of theRecipient
end if

set theTaskTitel to theRecipientName & (ASCII character 202) & MidFix & (ASCII character 202) & theSubject
set messageURL to "Created from message://%3C" & (theMessageID) & "%3E"
set theBody to messageURL
if mailBody then set theBody to theBody & return & return & the content of theMessage

-- Add waiting for context task to OmniFocus
tell application "OmniFocus"
tell default document
set theContext to context myWFContext
make new inbox task with properties {name:theTaskTitel, note:theBody, context:theContext}
end tell
end tell
my GrowlSuccess("Mail: " & theSubject)
end repeat
end tell

end perform_mail_action

on GrowlSuccess(theMessage)
if GrowlRun then tell application "GrowlHelperApp" to notify with name notifySuccess title titleSuccess description theMessage & txtSuccess application name scriptName
end GrowlSuccess

on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode[/CODE]

Omnipper 2010-04-26 01:17 PM

Thanks Brett,

I ♥ this script. Works great!

--Marc

bpwhistler 2010-04-26 01:27 PM

[QUOTE=Omnipper;76470]Thanks Brett,

I ♥ this script. Works great!

--Marc[/QUOTE]

Not a problem...but the thanks truly goes to simplicityisbliss for writing and sharing such a great script.

kaijin 2010-04-30 05:36 PM

Would it be possible to modify simplicitybliss' wonderful script so that a project (that already exist in OF) and due date assigned via MailTags are grabbed and applied to the waiting for tasks in OF?

smorr@indev.ca 2010-05-05 11:15 AM

Revised AppleScript to make use of MailTags Project and Tickle Dates when composing
 
I have taken the liberty to modify the script created by simplicityIsBliss to add further MailTags compatibility.

This works really well if you set the criteria of the outbox rule to be tickle date is more than 0 days after today. (ie the future), it will run the script when you send a message with a tickle date on and add the task to OmniFocus.

Note -- I have to get Outbox rules working with exchange. I expect this will be soon.


[CODE](*
Waiting For Mails to OmniFocus Script
by simplicityisbliss.com, Sven Fechner
MailTags project and due date compatibility added by Scott Morrison, Indev Software

Based on an Outbox Rule (Mail Act-On) in Mail.app this script adds specific messages
to the OmniFocus Inbox with the waiting for context

MailTags is required to automatically set the project and the due date.

Mail Act-On (www.indev.ca) is required to define the Outbox Rule to only
create tasks for those outgoing emails that are to be tracked in OmniFocus

A sample Outbox rule may be
if MailTags Tickle Date is After 0 days today
Run Apple Script: [ThisAppleScript]


The script uses Growl for feedback notification if it is installed and running

*)


--!! EDIT THE PROPERTIES BELOW TO MEET YOUR NEEDS !!--

-- Do you want the actualy mail body to be added to the notes section of the OmniFocus task?
-- Set to 'true' is or 'false' if no
property mailBody : true

-- Text between mail recipient (the person you are waiting for to come back) and the email subject
property MidFix : "to follow up re:"

-- Name of your Waiting For context in OmniFocus
property myWFContext : "Waiting For"

-- !! STOP EDITING HERE IF NOT FAMILAR WITH APPLESCRIPT !! --

--Configuration for Growl messages
property GrowlRun : false
property scriptName : "Waiting For Mails to OmniFocus"
property notifySuccess : "Success Notification"
property notifyFail : "Failed Notification"
property titleSuccess : "Waiting For Mail added"
property titleFail : "Waiting For Mail to OmniFocus FAILED"
property txtSuccess : " added to OmniFocus successfully"
property txtFail : " to OmniFocus to add successfully"
property txtIcon : "OmniFocus"

on perform_mail_action(theData)

--Check if Growl is running
tell application "System Events" to set GrowlRun to (count of (every process whose name is "GrowlHelperApp")) > 0

--Setup Growl
if GrowlRun then tell application "GrowlHelperApp" to register as application scriptName all notifications {notifySuccess, notifyFail} default notifications {notifySuccess, notifyFail} icon of application txtIcon

--Get going
tell application "Mail"
set theMessages to |SelectedMessages| of theData --Extract the messages from the rule
repeat with theMessage in theMessages
set theSubject to subject of theMessage
set theRecipient to name of to recipient of theMessage
set theMessageID to urlencode(the message id of theMessage) of me
try
using terms from application "MailTagsScriptingSupport"
set myProject to project of theMessage
set theDueDate to due date of theMessage
end using terms from
on error theError

end try

-- Check if there is one or more recipients
try
if (count of theRecipient) > 1 then
set theRecipientName to (item 1 of theRecipient & (ASCII character 202) & "and" & (ASCII character 202) & ((count of theRecipient) - 1) as string) & (ASCII character 202) & "more"
else
set theRecipientName to item 1 of theRecipient
end if

set theTaskTitel to theRecipientName & (ASCII character 202) & MidFix & (ASCII character 202) & theSubject
set messageURL to "Created from message://%3C" & (theMessageID) & "%3E"
set theBody to messageURL
if mailBody then set theBody to theBody & return & return & the content of theMessage

-- Add waiting for context task to OmniFocus
tell application "OmniFocus"
tell default document
set theContext to context myWFContext
set theTask to make new inbox task with properties {name:theTaskTitel, note:theBody, context:theContext, due date:theDueDate}
if myProject is not "" then
set theProject to project myProject
move theTask to end of tasks of theProject

end if
end tell
end tell

on error theError
do shell script "logger -t outboxrule 'Error : " & theError & "' "
end try

my GrowlSuccess("Mail: " & theSubject)
end repeat
end tell

end perform_mail_action

on GrowlSuccess(theMessage)
if GrowlRun then tell application "GrowlHelperApp" to notify with name notifySuccess title titleSuccess description theMessage & txtSuccess application name scriptName
end GrowlSuccess

on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode
[/CODE]


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

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