Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Operating System
Mail.app AppleScript does not execute as it is supposed to within Mail for Yosemite
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="TOTCOM11" data-source="post: 1636166" data-attributes="member: 342298"><p>Hello,</p><p></p><p>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.</p><p></p><p>Here is the website where I found the information:</p><p>https://support.omnigroup.com/omnifocus-2-mail-rule</p><p></p><p>Here is the code that I added to the appropriate folder that the article talks about:</p><p></p><p>---------------------</p><p></p><p>[CODE]-- Copyright 2014 The Omni Group. All rights reserved.</p><p></p><p>using terms from application "Mail"</p><p>-- Trims "foo <foo@bar.com>" down to "foo@bar.com"</p><p>on trim_address(theAddress)</p><p>try</p><p>set AppleScript's text item delimiters to "<"</p><p>set WithoutPrefix to item 2 of theAddress's text items</p><p>set AppleScript's text item delimiters to ">"</p><p>set MyResult to item 1 of WithoutPrefix's text items</p><p>on error</p><p>set MyResult to theAddress</p><p>end try</p><p>set AppleScript's text item delimiters to {""} --> restore delimiters to default value</p><p>return MyResult</p><p>end trim_address</p><p></p><p></p><p>on process_message(theMessage)</p><p>tell application "OmniFocus"</p><p>log "OmniFocus calling process_message in MailAction script"</p><p>end tell</p><p>set theSubject to subject of theMessage</p><p>set singleTask to false</p><p>if (theSubject starts with "Fwd: ") then</p><p>-- Whole forwarded messages shouldn't split.</p><p>set singleTask to true</p><p>set theSubject to rich text 6 through -1 of theSubject</p><p>end if</p><p>set theText to theSubject & return & content of theMessage</p><p>tell application "OmniFocus"</p><p>parse tasks into default document with transport text theText as single task singleTask</p><p>end tell</p><p>end process_message</p><p></p><p>on perform mail action with messages theMessages</p><p>try</p><p>set theMessageCount to count of theMessages</p><p>repeat with theMessageIndex from 1 to theMessageCount</p><p>my process_message(item theMessageIndex of theMessages)</p><p>end repeat</p><p>on error m number n</p><p>tell application "OmniFocus"</p><p>log "Exception in Mail action: (" & n & ") " & m</p><p>end tell</p><p>end try</p><p>end perform mail action with messages</p><p>end using terms from[/CODE]</p><p>----------</p><p></p><p>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.</p><p></p><p>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.</p><p></p><p>Thanks,</p><p>Chris</p></blockquote><p></p>
[QUOTE="TOTCOM11, post: 1636166, member: 342298"] 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 <foo@bar.com>" down to "foo@bar.com" 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[/CODE] ---------- 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 [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Operating System
Mail.app AppleScript does not execute as it is supposed to within Mail for Yosemite
Top