Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

NMPOP3 question

Posted on 2001-08-30
4
Medium Priority
?
252 Views
Last Modified: 2010-04-06
How can I know when I have received a new mail item to my exchange server via NMpop3 component? I can connect ok, I need some sort of a message to know when I received a new mail.

Thanks
0
Comment
Question by:drnadeem
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Phoenix_s
ID: 6446278
check the server every X minutes using a timer

I believe that's how most mail clients do it

it'll tell you if you have new mail
0
 
LVL 1

Expert Comment

by:DelRunner
ID: 6504044
There ar several ways to check this, but a simple one is to store the number of messages in your mailbox everytime you connect, and then compare with the number of messages at the previous connection.
Edit1.Text holds the previous number of mails

procedure TForm1.Button1Click(Sender: TObject);
var
  mails : Integer;

begin
  NMPOP31.Connect;
  mails:=0;
  if NMPOP31.Connected then
  begin
    NMPOP31.List;
    mails:=mails+1;
  end;
  if mails > StrToInt(Edit1.Text) then
    ShowMessage('You got new mail');
  Edit1.Text:=IntToStr(mails);
  MNPOP31.Disconnect;
end;



The best way is the store and compare the MessageId's
0
 
LVL 1

Accepted Solution

by:
DelRunner earned 300 total points
ID: 6512596
..sorry, I found an error in my sample code.
Here's the right one:

var
  Form1: TForm1;
  mails : Integer;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
  NMPOP31.Connect;
  mails:=0;
  if NMPOP31.Connected then
  begin
    NMPOP31.List;
 end;
 if mails > StrToInt(Edit1.Text) then
   ShowMessage('You got new mail');
 Edit1.Text:=IntToStr(mails);
 NMPOP31.Disconnect;
end;

procedure TForm1.NMPOP31List(Msg, Size: Integer);
begin
  mails:=mails+1;
end;
0
 
LVL 1

Author Comment

by:drnadeem
ID: 6539609
sorry for the late reply... but I as away on holidaying :)-
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question