Hello,
Try to run from index 1 instead of index 0...
Delphi-Quellcode:
Function TMailTrans.GetInboxItemBySender(aSender : String) : Variant;
Var Index : Integer;
aMailItem : Variant;
Begin
Result:=NULL;
For Index := InboxFolder.Items.Count downto 1 do
begin
aMailItem:=InboxFolder.Items.Item(Index);
If aMailItem.sendername=aSender Then Result:=aMailItem;
end;
End;
Better to run from last item to the first. If you delete in a loop a mailitem then the order of the mailitems will change and ofcourse the count will also change.
Greets,
Delphi-Lover.