howie_
13 years agoContributor
Sorting Outlook email messages
Hi,
I've got a piece of code that is intended to retrieve the newest email message from Outlook. I'm trying to use the Sort() function, as implemented below, but it doesn't seem to be working as expected. The GetFirst() and Item(1) functions both return an email message that are nowhere near the most recent. Can anyone explain how I can implement the Sort() function? Otherwise I'm stuck iterating through all 600+ message items in the inbox searching for the right one.
var OutlookApplication = Sys.OleObject("Outlook.Application");
var NamespaceMAPI = OutlookApplication.GetNamespace("MAPI");
NamespaceMAPI.Folders(testAccount).Folders("Inbox").Items.Sort("Received", true);
var firstItem = NamespaceMAPI.Folders(testAccount).Folders("Inbox").Items.GetFirst();
var indexOneItem = NamespaceMAPI.Folders(testAccount).Folders("Inbox").Items.Item(1);
Thanks!
I've got a piece of code that is intended to retrieve the newest email message from Outlook. I'm trying to use the Sort() function, as implemented below, but it doesn't seem to be working as expected. The GetFirst() and Item(1) functions both return an email message that are nowhere near the most recent. Can anyone explain how I can implement the Sort() function? Otherwise I'm stuck iterating through all 600+ message items in the inbox searching for the right one.
var OutlookApplication = Sys.OleObject("Outlook.Application");
var NamespaceMAPI = OutlookApplication.GetNamespace("MAPI");
NamespaceMAPI.Folders(testAccount).Folders("Inbox").Items.Sort("Received", true);
var firstItem = NamespaceMAPI.Folders(testAccount).Folders("Inbox").Items.GetFirst();
var indexOneItem = NamespaceMAPI.Folders(testAccount).Folders("Inbox").Items.Item(1);
Thanks!