[CLOSED] IMAP Synapse - Check if there are new messages lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- pcurtis · 2021-10-05 13:55 I can login to my email providers server, get mails and so on. What logic do I have to use see if there are new messages? ---------------------------------------------------------------------- paweld · 2021-10-05 14:33 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  imapsend, mimemess, ssl_openssl, ssl_openssl_lib, synacode,  mimepart, synachar; procedure TForm1.Button2Click(Sender: TObject);var  ImapClient: TIMAPSend;  ListaMsg, Msg: TStringList;  i, j: Integer;begin  ListaMsg := TStringList.Create;  Msg := TStringList.Create;  ImapClient := TIMAPSend.Create;  ImapClient.TargetHost := mailhost;  ImapClient.TargetPort := mailport;  ImapClient.UserName := maillogin;  ImapClient.Password := mailpasswd;  ImapClient.AutoTLS := True;  ImapClient.FullSSL := True;  ImapClient.Login;  ImapClient.SelectFolder('INBOX');  if ImapClient.SearchMess('UNSEEN', ListaMsg) then  begin    for i := 0 to ListaMsg.Count - 1 do    begin      Msg.Clear;      ImapClient.FetchMess(StrToInt(ListaMsg[i]), Msg);      memo1.Lines.Add(msg.Text);      memo1.Lines.Add('---');    end;  end;  Msg.Free;  ListaMsg.Free;end; ---------------------------------------------------------------------- pcurtis · 2021-10-05 14:40 I haven't tried but won't that just show unseen messages? And fetchmess will mark the message as read. ---------------------------------------------------------------------- Remy Lebeau · 2021-10-05 16:49 Quote from: pcurtis on October 05, 2021, 04:40:45 pmI haven't tried but won't that just show unseen messages? Yes.  You could alternatively try 'NEW' instead, which searches for messages that are both '\Recent' and '\Unseen'. Quote from: pcurtis on October 05, 2021, 04:40:45 pmAnd fetchmess will mark the message as read. I don't know. It depends on what criteria Fetchmess() actually retreives.  Not all FETCH parameters set the '\Seen' flag on a message. ---------------------------------------------------------------------- pcurtis · 2021-10-06 05:17 thanks paweld and Remy Lebeau for putting me on the right path.