Delphi - Search E-mail with IMAP4 (Code returns true for false results)

Asked

Viewed 26 times

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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.