Quote:
Originally Posted by wesley.elder
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:
Code:
property folderPath : missing value
set folderPath to ((path to home folder from user domain as string) & "oo2of:tmp")
--TEST IF FOLDER EXISTS. IF NOT CREATE IT
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:
Code:
tell application "Microsoft Outlook"
repeat with aMessageId in idsOfFlaggedEmails
set theMsg to message id aMessageId
-- DO SOMETHING USEFUL
end repeat
end tell
I got the idea to mine the metadata from the Data Records files on the filesystem from here:
http://blog.stevex.net/2011/03/outlo...ith-raw-query/