The Omni Group Forums

The Omni Group Forums (
-   OmniFocus 1 for Mac (
-   -   Outlook Flagged Messages (

wesley.elder 2012-10-10 08:54 PM

Outlook Flagged Messages

I've just read this article about sending flagged messages to omnifoucs. /links/send-flagged-mail-messages-to-omnifocus-automatically

I currently use outlook, i would like to do something similar.

I would like to mark messages as flagged on my iPhone/idevice, when they arrive in my inbox (or update to flagged) i want to send the main to my omnifoucs inbox.


1. mark as flagged, in outlook/iphone/ipad
2. search inbox every x mins / or based on an event? (ON MAC - so has to be running for this to work)
3. send selected messages to omnifoucs inbox
3. mark messages as unflagged

Any ideas?

Ive looking he dictionary for outlook there is a property followup seems to be the right one?

So for now i would just like to know how to list all flagged messages, i can do the rest.


denno 2012-10-12 06:19 AM

I was thinking the exact same thing. Please share if you figure it out...

wesley.elder 2012-10-12 08:24 PM

Hey Denno,

i downlaoded scriptbug from [URL=""][/URL]

i was able to debug the script with breakpoints and look at each object.

I then found the todo flag property of the message.

--Assuming your message has been assigned to theMessage
set flagged to todo flag of theMessage as text[/PHP]

you can then

[PHP]if flagged is "not completed" then
--do something amazing with flagged message
end if


I now want to un-flag the message, but i dont know how to do that, (new to this applescript stuff)


wesley.elder 2012-10-12 08:35 PM

OK this works:

[PHP]set todo flag of theMessage to completed[/PHP]

now to tidy up and find some way to run its every x mins..

wesley.elder 2012-10-13 07:12 PM


so im a little stuck with this script now.

i can get all the flagged mails from my account using the code below and send the flagged mail to omnifoucs:

set thisAccount to exchange account "MYEXCHANGEACCOUNT"
set thisFolders to mail folder of thisAccount

repeat with theFolder in thisFolders
if name of theFolder is "Inbox" then

set selectedMessages to messages of theFolder

repeat with theMessages in selectedMessages

if ((todo flag of theMessages) is not completed) then
--Send to OmniFoucs

end if
end repeat
end if
end repeat

But its slow!

in the script i referenced you can do the following with the mail app:

[PHP]set _msgs_to_capture to (a reference to
(every message of _inbox
whose flagged status is true))[/PHP]

Is this type of command available in outlook?
i can't get it to work

Is there a faster way to query the the database just to return the flagged emails?

Smart Folders have flagged mail in them, they return (within outlook) in a second. Does anyone know how i can access them?

Either via outlook apple script, or system events?

I've got the script to catch flagged new mail when they arrive via rules, however if the mail is already read then it will not catch it.


fudster 2014-05-02 08:17 PM


But its slow!

Is there a faster way to query the the database just to return the flagged emails?


I have a solution working here:

property folderPath : missing value

set folderPath to ((path to home folder from user domain as string) & "oo2of:tmp")
if (do shell script "/bin/test -e " & quoted form of (POSIX path of folderPath) & " ; echo $?") is "1" then
-- 1 is false
do shell script "/bin/mkdir -p " & quoted form of (POSIX path of folderPath)
end if

set msOutlookDataDir to "~/Documents/Microsoft User Data/Office 2011 Identities/Main Identity/Data Records/Messages/0T/0B/0M"

set timestampFileFullName_notposix to folderPath & ":timestamp"
set timestampFileFullName to quoted form of (POSIX path of timestampFileFullName_notposix)

set timestampFile to missing value
set newerString to ""
set touchString to " && touch " & timestampFileFullName
tell application "Finder"
if file (timestampFileFullName_notposix) exists then
set newerString to "-newer '" & timestampFileFullName & "'"
end if
end tell

set cmd to "cd \"~/Documents/Microsoft User Data/Office 2011 Identities/Main Identity/Data Records/Messages/\" && find . -type f " & newerString & " -exec mdls -name com_microsoft_outlook_flagged -name com_microsoft_outlook_recordID {} \\; | grep \" 1$\" -A1 | grep com_microsoft_outlook_recordID | awk ' { print $NF } ' " & touchString

set cmdResult to do shell script cmd
set idsOfFlaggedEmails to paragraphs of cmdResult


this will populate idsOfFlaggedEmails with a list of the message (document) IDs that have been flagged since the last time the script was run. From here, you can script however wish to tell Outlook to act on those messages:

tell application "Microsoft Outlook"
repeat with aMessageId in idsOfFlaggedEmails
set theMsg to message id aMessageId
end repeat
end tell

I got the idea to mine the metadata from the Data Records files on the filesystem from here: [url][/url]

All times are GMT -8. The time now is 06:38 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2022, vBulletin Solutions, Inc.