How to delete emails from POP3 server using Indy?

I would like to delete mail with a specific header or specific sender with INDY 10 / DELPHI. I can already request an email account at INDY10. Here's a demo code:

procedure TForm1.BtnCheckClick(Sender: TObject);
var
  i: Integer;
  Msg: TIdMessage;
  MailCount: Integer;
begin
  if IdPop31.Connected then
  begin
    MailCount := IdPOP31.CheckMessages;
    lbMailCount.Caption := IntToStr(MailCount);
    lbMailboxSize.Caption := IntToStr(IdPOP31.RetrieveMailBoxSize) + ' Bytes';

    for i := 1 to MailCount do
    begin
      Msg := TIdMessage.Create;
      try
        IdPOP31.RetrieveHeader(i, Msg);
        MailsList.Lines.Add(Msg.Subject + ' from ' + Msg.From.Text);
      finally
        Msg.Free;
      end;
    end;
  end;
end;

      

+3


source to share





All Articles