Mail.app AppleScript does not execute as it is supposed to within Mail for Yosemite

Joined
Jan 23, 2015
Messages
1
Reaction score
0
Points
1
Hello,

I am an avid user of OmniFocus and found out recently that I can use AppleScript within the Mail.app environment to add tasks from the email into OmniFocus automatically.

Here is the website where I found the information:
https://support.omnigroup.com/omnifocus-2-mail-rule

Here is the code that I added to the appropriate folder that the article talks about:

---------------------

Code:
-- Copyright 2014 The Omni Group.  All rights reserved.

using terms from application "Mail"
-- Trims "foo <[email protected]>" down to "[email protected]"
on trim_address(theAddress)
try
set AppleScript's text item delimiters to "<"
set WithoutPrefix to item 2 of theAddress's text items
set AppleScript's text item delimiters to ">"
set MyResult to item 1 of WithoutPrefix's text items
on error
set MyResult to theAddress
end try
set AppleScript's text item delimiters to {""} --> restore delimiters to default value
return MyResult
end trim_address


on process_message(theMessage)
tell application "OmniFocus"
log "OmniFocus calling process_message in MailAction script"
end tell
set theSubject to subject of theMessage
set singleTask to false
if (theSubject starts with "Fwd: ") then
-- Whole forwarded messages shouldn't split.
set singleTask to true
set theSubject to rich text 6 through -1 of theSubject
end if
set theText to theSubject & return & content of theMessage
tell application "OmniFocus"
parse tasks into default document with transport text theText as single task singleTask
end tell
end process_message

on perform mail action with messages theMessages
try
set theMessageCount to count of theMessages
repeat with theMessageIndex from 1 to theMessageCount
my process_message(item theMessageIndex of theMessages)
end repeat
on error m number n
tell application "OmniFocus"
log "Exception in Mail action: (" & n & ") " & m
end tell
end try
end perform mail action with messages
end using terms from
----------

Utilizing the console, I can see that when the correct email comes into my inbox, that the code is "running", however, the tasks in the email are not getting uploaded into OmniFocus.

Is this an issue with the code in your opinion, or is this more of an issue with Yosemite? The article specifically says the OS needs to be Mavericks or higher.

Thanks,
Chris
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top