euras wrote:But maybe there Is a better way to deal with it without those tricks?
I thought I gave you a better way of doing it but you seemed to simply ignore it and continue doing it your way by index.
Code: Select all
F10::
olApp := ComObjCreate("Outlook.Application")
olNameSpace := olApp.GetNamespace("MAPI")
olFolder := olNameSpace.Folders(1).Folders("Innboks").Folders("Favoritter") ; Could use Account DisplayName in place of index of 1
olItems := olFolder.Items
olItems.Sort("Received", true) ; true or false for descending or ascending
for Item in olItems
MsgBox % Item.Subject
return
The index of mail items is not guaranteed to be in the order received, either descending or ascending. In my experience it mostly is but not always exactly.
The Sort command allows you to put the mail items in any sort order you like. By received time, subject, from, etc.
FG