URL : Display Title : AppleScript

Hi …

If I use the ‘Send to Inbox’ shortcut for OSX mail.app, the new task has a nice “Original Message” format; with the URL embedded inside.

This appears to have some sort of XML property that sets a ‘Display Title’ value to the URL in the Note field of the new task.

However, when I do the standard applescript import for mail items, with the message:// syntax, all I get is an ugly link where the ‘Display Title’ is set to the same as the URL.

Does anyone know of a way to set the ‘Display Title’ using an AppleScript ? It would be nice to do it during the task import, but I could do some sort of secondary action if need be; once the item is a task.

Have you looked at Rentzsch’s AppleScript version of Clip O Tron?

(*
OmniFocus Selected Mail Messages.applescript
	Copyright (c) 2015 Jonathan 'Wolf' Rentzsch: http://rentzsch.com
	Some rights reserved: http://opensource.org/licenses/mit
  
Pure AppleScript reimplementation of OmniGroup's Clip-o-Tron for OmniFocus.

Hopefully this implementation will be more resilient against OS X, Mail, and OmniFocus updates.
Successfully tested against OS X 10.10.1, OmniFocus 1.10.6, and OmniFocus 2.0.4.

References:
<http://daringfireball.net/2007/12/message_urls_leopard_mail>
<http://forums.omnigroup.com/showthread.php?t=30754>
<http://shawnblanc.net/box/smarter_clip-o-tron.txt>
 *)

tell application "Mail"
	set _sel to the selection
	repeat with _msg in _sel
		set _msgSubject to _msg's subject
		set _msgBody to _msg's content
		set _msgSender to _msg's sender
		set _msgURL to "message://<" & _msg's message id & ">"
		tell application "OmniFocus"
			tell quick entry
				set _task to make new inbox task with properties {name:_msgSubject, note:_msgBody}
				tell note of _task
					insert "From: " & _msgSender & "  Original Message" & (ASCII character 10) & (ASCII character 10) at before paragraphs
					set value of attribute "link" of style of characters -1 thru -17 of first paragraph to _msgURL
				end tell
			end tell
		end tell
	end repeat
end tell

tell application "OmniFocus"
	tell quick entry to open
end tell
tell application "System Events" to keystroke tab

Perfect, with a little manipulation that made it work.

Thanks.

To anyone whom is interested. My ‘workflow’ is to stick emails into 2 folders for each email account I own.
Either it’s an ‘Action’ or something to ‘Follow Up’. This is the script that parses all that.

set vCounter to 0
set aFolders to {“Action”, “Follow Up”}
tell application “Mail”
repeat with oAccount in every account
set vAccountName to name of oAccount
repeat with vFolder in aFolders
if (exists mailbox vFolder in oAccount) then
repeat with oMessage in (every message of mailbox vFolder in oAccount)
if (flagged status of oMessage is false) then
set vSubject to "- " & subject of oMessage
set vSender to sender of oMessage
set vID to get message id of oMessage
set vURL to “message://<” & vID & “>”
set vTaskText to vSubject & return & vURL & return
tell application “OmniFocus”
tell quick entry
set _task to make new inbox task with properties {name:vSubject}
tell note of _task
insert “From: " & vSender & " Original Message” & (ASCII character 10) & (ASCII character 10) at before paragraphs
set value of attribute “link” of style of characters -1 thru -17 of first paragraph to vURL
end tell
end tell
end tell
set flagged status of oMessage to true
set vCounter to vCounter + 1
end if
end repeat
end if
end repeat
end repeat
end tell
if (vCounter is not equal to 0) then
set vNotificationMsg to “Processed " & vCounter & " email message(s).”
display notification vNotificationMsg with title “Scheduled ApppleScript” subtitle “eMail to OmniFocus”
end if
tell application “OmniFocus”
tell quick entry to save
end tell
tell application “System Events” to keystroke tab