(11-28-2023, 05:31 PM)eldonfsr Wrote: if(IDIMAP.Connected=false) then begin;
SetLength(SearchInfo, 1);
SearchInfo[0].SearchKey := skUnseen;
IDIMAP.UIDSearchMailBox(SearchInfo);
end else begin
SetLength(SearchInfo, 1);
SearchInfo[0].SearchKey := skUnseen;
IDIMAP.UIDSearchMailBox(SearchInfo); // here is generated the error
end;
You have an erroneous ; on the begin of your if statement (I'm surprised the code compiles at all). You need to remove that ;
if(IDIMAP.Connected=false) then begin; // <-- HERE
Besides that, you are executing UIDSearchMailBox() regardless of whether Connected is True or False. The error message is telling you that are in the Authenticated state, which means you don't have a mailbox selected. You need to select a mailbox before you can search its emails. There is no command to search an un-selected mailbox.

