![]() |
Retrieving and setting current sort order
Howdy all.
Have short VBScript that creates an Outlook obj and looks for a mail item with a specific subject line. Was wondering how to obtain the user's current inbox sort order so I can change it to descending to ensure the most recent email w/desired subject is the first mail item found and then return it to the user's previous selection. I can set the sort below but have not yet found how to obtain the current sort order... ' set sort order of inbox olInBox.Items.Sort "Received", True Appreciate your suggestions/comments. Thank you, Rey |
Retrieving and setting current sort order
Found what works for me...and hopefully for others having encountered
similar problem. Had to define a vbScript var as olInBoxItems and SET this to the default InBox folder Items collection. Then the sort desc work. So here's the vbScript code: ' create Outlook app set objOutLook = CreateObject("Outlook.Application") 'msgbox "OutLook app obj created" set olNameSpace = objOutLook.GetNameSpace("MAPI") 'msgbox "OutLook NameSpace obj created" ' get inbox set olInBox = olNameSpace.GetDefaultFolder(olFolderInBox) 'msgbox "OutLook InBox obj created" ' set sort order of inbox - DOESN'T SORT 'olInBox.Items.Sort "[Received]", True SET olInBoxItems = olInBox.Items ' now sort desc - WORKS olInboxItems.Sort "[Received]", True ' find the email subj 'set olMailItem = olInBox.Items.Find(strFilter) set olMailItem = olInBoxItems.Find(strFilter) ' found email if not (olMailItem is Nothing) then ' file into which email body is saved to for later reading strTempFile = "\LienReleaseBody.txt" ' proc to write out & read contents of msgbody strLiens = GetAndReadMessageBody(olMailItem.Body, strTMPFolder & strTempFile) end if ' closing Outlook objs SET olInBoxItems = Nothing set olMailItem = Nothing set olInbox = Nothing set olNameSpace = Nothing set objOutLook = Nothing Similar code works in vb.net. |
All times are GMT +1. The time now is 05:16 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com