This is a bit of an arcane question, but hoping someone has some experience to help.
I have an AppleScript routine I’ve used for some time that I use to triage email. The script presents a variety of choices, including commands to set the follow-up dates for a message. The script uses UI commands to choose items from the contextual Microsoft Outlook “Follow-Up” menu that presents when command clicking on an Outlook message.
This is married with an Outlook Smart Folder that shows me messages flagged as due today or earlier. The data element the Smart Folder references for due date is
This all works fine.
Here’s the problem I’m facing. I’ve re-written the applescript to directly set the
due date for the message rather than going down the UI scripting path. See script snippet below. The steps I’m referring to follow the
set theDoLaterFolder... line
The script is working as expected in terms of
due date (and other message attributes… eg destination folder) being set correctly. I can see the new due date in Outlook when I look at the message. However, it seems the internal
kMDItemDueDate is not getting set.
kMDItemDueDate is set when choosing the “Follow-Up” flag from the Outlook UI. It does not appear to get set when manually updating
due date via AppleScript. At least that is my supposition after extensive troubleshooting.
kMDItemDueDate is not set, the smart folder rule will never fire.
Assuming that makes sense, any ideas on forcing a value to kMDItemDueDate?
AppleScript snippet for inbox triage
tell application "Microsoft Outlook" set theSelectedMessage to selected objects repeat with theMessage in theSelectedMessage set theAction to text returned of (display dialog "Archive, Search or Days" default answer "") if theAction is "false" then return else if theAction = "S" then my doSearch(theMessage) return else if theAction = "A" then set theArchiveFolder to folder "2019" of folder "Inbox" of account of theMessage set is read of theMessage to true set todo flag of theMessage to not flagged move theMessage to theArchiveFolder return else set theDoLaterFolder to folder "Do Later" of folder "Inbox" of account of theMessage set is read of theMessage to true set todo flag of theMessage to not completed set due date of theMessage to ((current date) + theAction * days) move theMessage to theDoLaterFolder end if end if end repeat end tell
In case you are interested, the following is the raw query used for the Smart Rule (again, this rule works as expected when a message is flagged via the Follow-Up menu — either direct or through UI scripting). It does not work when
due date is set via the script.