Applescript outlook search mail

Hi,


is there anyway to seach within outlook via applescript?


I would like to find a way to find flagged mail then perform an action on it.


i can do somthing like:


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



how ever the line


set selectedMessages to messages of theFolder


takes a very long time - seems its assigning all the emails into a list and takes forever, maybe i can refenerence them somehow?



you can do the following in mail :

set _msgs_to_capture to (a reference to ¬
(every message of _inbox ¬
whose flagged status is true
))



This is very fast but i cant find anyway to this for outlook.


Smart Folders work really quickly - can i access them anyway in applescript?


Thanks,

Wes

OS X Mountain Lion (10.8.2)

Posted on Oct 15, 2012 3:16 AM

Reply
5 replies

Oct 15, 2012 8:02 AM in response to adayzdone

thanks,


it did come back with all the flagged emails:


, {incoming messageid 175340}, {}, {incoming messageid 131140, incoming messageid 131195, incoming messageid 131461, incoming messageid 131572, incoming messageid 129355, incoming messageid 129568, incoming messageid 130111, incoming messageid 128217, incoming messageid 128239, incoming messageid 128477, incoming messageid 127738, incoming messageid 138908, incoming messageid 138907, incoming messageid 142217, incoming messageid 144631, incoming messageid 147003, incoming messageid 153231, incoming messageid 161894, incoming messageid 168142, incoming messageid 175337, incoming messageid 175980, incoming messageid 175979}, {}, {}, {}, {}, {}, {}}


However it seems like it loops through every single message to get there, took 2.36mins to do this.


There is no way to use the search feature, or smart folders?


Im missing something obvious i feel

Oct 15, 2012 8:59 AM in response to wesley.elder

So turns out the search in Outlook uses spotlight!


reference this link: http://blog.stevex.net/2011/03/outlook-2011-smart-folder-with-raw-query/


after playing around i can now:


set Files_Found to paragraphs of (do shell script "mdfind com_microsoft_outlook_flagged==2&&com_microsoft_outlook_folderID==722")

repeat with i in Files_Found

-- Do somthing useful.

end repeat


So now i have a list of file names to all the flagged emails in my inbox, this returns in 0.18 secs pretty fast, what im looking for!


Now i want to get some info from them, send them to Omnifocus and unflag, the search continues!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript outlook search mail

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.