Forum > Networking and Web Programming

[CLOSED] IMAP Synapse - Check if there are new messages

(1/1)

pcurtis:
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:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
I haven't tried but won't that just show unseen messages?
And fetchmess will mark the message as read.

Remy Lebeau:

--- Quote from: pcurtis on October 05, 2021, 04:40:45 pm ---I haven't tried but won't that just show unseen messages?

--- End quote ---

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 pm ---And fetchmess will mark the message as read.

--- End quote ---

I don't know. It depends on what criteria Fetchmess() actually retreives.  Not all FETCH parameters set the '\Seen' flag on a message.

pcurtis:
thanks paweld and Remy Lebeau for putting me on the right path.

Navigation

[0] Message Index

Go to full version