highlight a mail message after importing

hello folks,

I want to set a different text color to all messages in mail when they are already stored in DT.

Of course I can change the “add to DT” script, that is what I have already done, but this will only works correctly, if the user never used one of the other mechanisms to import mails (drag & drop etc.)

So what I need right now is a way to double check if a message is already in the database or not.

mail offers the ID and the message ID… both things that are not available in DT.

DT offers path (which is used to open the message in mail again), but this stuff is not accessible in the mail dictionary.

any idea?

best regards

thorsten

You might consider using Mail ActOn for this. (Full disclosure, though: I’ve uninstalled Mail ActOn many times because it gets to the point of seriously misbehaving and messing with memory - it’s on my current banned list. YMMV)

Otherwise, some tricky scripting to monitor Mail and DT might work.

Or, simply, change the message color before you add the message to DT.

hello korm,

thx for your reply. I guess I have already an idea how to manage the “background process” but I don’t have any idea how to find out if a message is already in the database or not

“exists record with path” will not work, because mail do not provide the path or I’m to stupid to find it.

the only way I see right now is the extract the message id out of the “reference url” property…

anyone with a better idea?

Here is the script that will highlight messages in apple mail which are already imported to devon think.


using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			set theUUID to ""
			set theDevonItem to ""
			repeat with theMessage in theMessages
				set theUUID to message id of theMessage
				#uuid's are stored in DT and mail a little bit different, that the reason for the next line of code
				set theUUID to ("<" & theUUID & ">")
				tell application "DEVONthink Pro"
					set theDevonItem to (get record with uuid theUUID)
				end tell
				if theDevonItem is not missing value then
					set background color of theMessage to gray
				end if
			end repeat
		end tell
	end perform mail action with messages
end using terms from

it is implemented as a mail rule, which of course is not really the right way. Normally a mail rule will be triggered when a new mail come in… still you can just select all mails and invoke the rule manually.

another option would be to run it in an endless loop as a background process.

anyone with a better idea?