0
Hello, good morning, sir. I am developing an application that needs to access the email, through IMAP4, and search a certain term in the body of the email or subject. The problem is that I have the code and it returns true even when it does not find a certain term in the email. I’ll post here and I’d like your help.
procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  MsgObject: TIdMessage;
  SearchInfo: array of TIdIMAP4SearchRec;
begin
    SetLength(SearchInfo, 1);
    SearchInfo[0].SearchKey := skUnseen;; // < Apenas msg não lidas
    SearchInfo[0].Text := 'CADASTRO REALIZADO'; //< Código a ser pesquisado
    if IMAPClient.SearchMailBox(SearchInfo) then
    begin
     ShowMessage('E-mail encontrado');     //< Ele retorna verdadeiro mesmo não encontrando a mensagem 
    end;
End;
I am already logged in and in the inbox, INBOX. I do not know where the error is, because the code does not generate any error or Exception. Can anyone help me? Thank you.
see if this thread helps: https://stackoverflow.com/questions/13612968/how-to-search-for-a-specific-e-mail-message-in-imap-mailbox
– JMSlasher
It worked. Thank you!
– Cesar