Here is a simple tutorial on how to make a useful little program that can check your e-mail inbox for new messages, and notify you about it. If you save the finished EXE file on your hard disk, you can also configure windows to start it automatically when windows is loaded, and get notified when your inbox is checked for new messages.
Here is a checklist on what you need:
-Borland Delphi
-Installed Indy components (these are automatically installed if you are using Delphi 6 or Delphi 7)
Onward!
Create a new project in Delphi.
Select the Indy “IdPop3” component from the “Indy Clients” tab and place it on your form.
Now, we need to make this component work. We will use this component to check our inbox when our program starts, and to do that, double click any part of the empty area on your form, and the code editor will show up allowing you to type the code that will be executed as soon as the form is created.
First, we need to define the variable that is going to contain the number of new messages. In this case, I called it “Status”. When defining variables in Delphi, you need to put them behind the main “begin” statement of the procedure, like this:
var Status:Integer;
begin
end;
This program will automatically end after we click on the OK button after we receive our notification, but the main form will still show up and hide itself very fast, which looks a bit ugly. So we will resize it and move it to the invisible part of the screen:
Form1.Height := 100;
Form1.Left := -500;
Form1.Top := -500;
Good. Now we need to input the needed information about the pop3 server that we are connecting to. Don’t forget to type in your information here:
idpop31.Password := 'your_password';
idpop31.Host := 'pop3.your_server.com';
Now for the code that will connect and retrieve the needed information. First we connect to the server, then the “idpop3” components retrieves the number of new messages, and disconnects from the server:
Status:=idpop31.CheckMessages;
idpop31.Disconnect;
Let’s show our notification:
If the number of messages is 0, the program will play a sound and show a message box that will inform us that we do not have any new messages. In this case, I used the “Windows XP Logoff” sound, but you can use any sound you like, as long as it is a WAV file:
IMPORTANT: In order to play the sound, you need to place the “mmsystem” unit in the “Uses” form:
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logoff Sound.wav',0,SND_ASYNC);
MessageDlg('You have no new messages.',mtInformation,[mbOK],0);
end;
If the message count is 1, then the program plays the “Windows XP Logon” sound and shows a notification message:
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logon Sound.wav',0,SND_ASYNC);
MessageDlg('You have 1 new message.',mtInformation,[mbOK],0);
end;
If the message count is larger than 1, then we do the same thing, except the message is slightly different:
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logon Sound.wav',0,SND_ASYNC);
MessageDlg('You have '+IntToStr(Status)+' new messages.',mtInformation,[mbOK],0);
end;
That’s about it! Any questions and comments are welcome.


Is there any pop3 project? when I get the mails it gives portions of this message may be unreadable without a mimie capable mail program
Cheers,
My pop3 doesn’t work correct.
I’ve getting “Connection Closed Gracefully” after around 10 secs
when calling the Connect method.
Can’t find the problem.
Any suggestions.
Regards