Is Category value of Outlook message set-able by script?

I am using DEVONthink again after a long hiatus. The “Send Message(s) to DEVONthink” script is quite useful. The captured metadata for the message is richer than what you get when sending Outlook messages to Microsoft OneNote (built-in Microsoft feature).

I want to enhance the script such that it sets the Category property of the currently processed message to a custom value, e.g. “Sent to DEVONthink”. Currently, I have to do it manually and it can only be done one message at a time.

I had seen somewhere online that the Category property may not set-able, wanted to make sure.

It also appears that the Category property is a list.

Thx

What “Category” property are you referring to?

To be clear, ‘category’ is a property of Message objects in Microsoft Outlook. So this is really a question about scripting Outlook, but I think the proposed enhancement would be appreciated by other DT users.

Outlook provides a way for the user to tag objects (messages, notes, calendar items, etc) with arbitrary labels. There can be more than one tag per object, for example, “Alert”, “Important”, “Milestone”, “Travel”. In my usage, I almost never have more than one tag, and it can be displayed as a column in the message listing in Outlook.

The applescript written by Christian Grunenber obtains the category (a list) for each outlook message and uses it to assign Tags for the item being imported into DevonThink.

I want to enhance the existing script. For each Outlook message the script sends to DEVONthink, I want to add a tag “Sent to DEVONthink” to the Outlook message. That way I can immediately see in Outlook which messages have already been sent to DT.

I will do some testing but I rarely code in AppleScript and it always trips me up.

MM.

Ok, I figured it out. It doesn’t check to see if the message already has the tag, but is a good partial solution. When getting the Outlook category, it returns a list of objects without their names, so the redundancy checking is a bit more challenging:

example:
category of theMessage
–> {category id 50 of application “Microsoft Outlook”}

Insert into the DevonTechnologies provided applescript “Add message(s) to DEVONthink”, some context of original script provided below:


set theCategories to {}
set theList to (category of theMessage)
repeat with theCategory in theList
set theCategories to theCategories & (name of theCategory)
end repeat

– start of inserted code
set end of theList to category “Sent to DEVONthink”
try
tell application “Microsoft Outlook” to set category of theMessage to theList
on error error_message number error_number
end try
– end of inserted code

set isFlagged to true

Version 2, this adds the tag to category only if it does not already exist. I also confirmed that if the message object has other tags assigned they are not disturbed.

Snippet with context of original script “Add message(s) to DEVONthink”:

set theCategories to {}
set theList to (category of theMessage)
repeat with theCategory in theList
set theCategories to theCategories & (name of theCategory)
end repeat

– start of inserted code
set devonTagged to false
repeat with theCategory in theList
if (name of theCategory) is “Sent to DEVONthink” then
set devonTagged to true
exit repeat
end if
end repeat
if devonTagged is false then set end of theList to category “Sent to DEVONthink”

try
tell application “Microsoft Outlook” to set category of theMessage to theList
on error error_message number error_number
end try
– end of inserted code

set isFlagged to true