Sorting outlook 2007 inbox

Giganews Newsgroups
Subject:Sorting outlook 2007 inbox
Posted by: Phil barber
Date:Mon, 30 Nov 2009

I have wrtten an applcation that has the users outlook 2007 inbox displayed with in it. the problem I am having is that I am getting comments that the sort order of the inbox gets garbled. below is my basic code that retrieves the mailitems:
......
// G1 is a Trz
var
MAPIFolder:olevariant;
j:integer;
G:TRzGroupItem;
begin
OlApp:=CreateOleObject('Outlook.Application');
Namespace:=OlApp.GetNameSpace('MAPI');
MAPIFolder:=Namespace.GetDefaultFolder(olFolderInbox);
  if MAPIFolder.Items.count>0 then
    for j:=MAPIFolder.Items.count downto 1 do begin
      G:=G1.Items.add;
      G.Caption :=MAPIFolder.Items[j].SenderName+' '+MAPIFolder.Items[j].subject+
      ' '+ dateToStr(MAPIFolder.Items[j].ReceivedTime); //
      List.Add(TItem.Create);
      Item:=List.items[List.count-1];
      Item.name:='File';
      Item.Letter:=MAPIFolder.Items[j];
      G.Data:=Item;
      G.OnClick:=OnItemClick;
    end;
end;

Replies