Sorting Inbox

D

Dan

Hi,
I'm trying to time the sorting of the inbox on various fields like this:

Set colItems = objFolderInbox.Items
MyStartTime = Now
colItems.Sort "From"
TimeToSortInbox = DateDiff("s",MystartTime,Now)

Unfortunately this is not an accurate reflection of sorting through the GUI.
Is it possible to actually get the user interface to sort through code?

Thanks,
Dan
 
A

Alan Moseley

You need to change the View that is currently being used. You can get to the
View by using:-

Dim oView as View
Set oView=ActiveExplorer.CurrentView

Next you need to change the underlying XML

dim sXML as String
sXML=oView.XML

Next, the trickiest bit, you need to edit this XML, specifically the section
entitled <orderby>. This is an example of my inbox which is sorted by
received date:-

<orderby>
<order>
<heading>Received</heading>
<prop>urn:schemas:httpmail:datereceived</prop>
<type>datetime</type>
<sort>desc</sort>
</order>
</orderby>

When you have updated this within sXML, load the updated string back into
the view:-

oView.XML=sXML

It 'aint easy, so best of luck!
 
K

Ken Slovak - [MVP - Outlook]

You can't directly sort via code but you could create a custom view that
does that and set that as the current view using code. Use
Explorer.CurrentView for that.
 
Top