Delphi - A Simple E-mail Notification System - Check the number of new e-mails messages

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

Delphi - A Simple E-mail Notification System - Check the number of new e-mails messages

bureX
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.

user posted image

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.

user posted image

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:

CODE

procedure TForm1.FormCreate(Sender: TObject);
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:

CODE

Form1.Width := 100;
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:

CODE

idPop31.Username := 'your_username';
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:

CODE

idpop31.Connect;
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:

user posted image

CODE

if Status = 0 then
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:

CODE

if Status = 1 then
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:

CODE

if Status > 1 then
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logon Sound.wav',0,SND_ASYNC);
MessageDlg('You have '+IntToStr(Status)+' new messages.',mtInformation,[mbOK],0);
end;


And finally, we close our program with this piece of code:

CODE

Application.Terminate;


The whole unit should look like this:

CODE

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
 IdTCPClient, IdMessageClient, IdPOP3, mmsystem;

type
 TForm1 = class(TForm)
   IdPOP31: TIdPOP3;
   procedure FormCreate(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var Status:Integer;
begin
Form1.Width := 100;
Form1.Height := 100;
Form1.Left := -500;
Form1.Top := -500;
idPop31.Username := 'your_username';
idpop31.Password := 'your_password';
idpop31.Host := 'pop3.your_server.com';
idpop31.Connect;
Status:=idpop31.CheckMessages;
idpop31.Disconnect;
if Status = 0 then
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logoff Sound.wav',0,SND_ASYNC);
MessageDlg('You have no new messages.',mtInformation,[mbOK],0);
end;
if Status = 1 then
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logon Sound.wav',0,SND_ASYNC);
MessageDlg('You have 1 new message.',mtInformation,[mbOK],0);
end;
if Status > 1 then
begin
PlaySound('C:\WINDOWS\Media\Windows XP Logon Sound.wav',0,SND_ASYNC);
MessageDlg('You have '+IntToStr(Status)+' new messages.',mtInformation,[mbOK],0);
end;
Application.Terminate;
end;

end.


Press F9 to run your program. If all goes as planned, the program will connect to your e-mail server and retrieve the number of new messages and display it as a dialog message:

user posted image

That’s about it! Any questions and comments are welcome.

 

 

 


Reply

whyme
Nice tutorial, now i can stop using outlook, lol

Reply

bureX
I guess you really can't get ANY MORE CREATIVE than that?

This is just the same scene when I wrote a tutorial about changing the start menu button caption. The start button was just AN EXAMPLE of what you could do with handles.

This is also an example, and there are countless possibilities what you can do with it!

In my case:

1)I extended this example and made a program that enables me be notified when I receive new e-mail messages when I turn on my computer, but I will also be notified when I receive an important message from my relatives.

2)I am also subscribed to a newsletter, and when I receive an email that is from the address that sends that newsletter, my program will automatically download it and show it on the screen (kind of like when somebody brings you the daily newspaper).

3)When I receive an e-mail from the phpBB newsletter, it usually means that a new security alert is found and/or there is a new version of phpBB available. There are many script kiddies around that get their hands on the fresh exploits around and can easily trash my forum. That's why I get notified right away when it arrives from my program.

In a sea of unread e-mail messages, spam and other junk mail, this small program is very useful to me.

BTW: When I read a tutorial, I usually try to learn something, not just follow the instructions, get the job done, congratulate myself on how smart and clever I am, and still know nothing.

 

 

 


Reply

karlo
Now, Delphi is a really user-friendly programming langauge! I must use it, i think. Or do you think I have to stick to VB? But I am not using VB for more than 2 years now. I love PHP though.

Reply

bureX
If you know Visual Basic, you should have no problem when learning Object Pascal (Delphi, that is). Just remember to put ";" on the end of every line, and instead of the "{" bracket, you will be using the "begin" word, and instead of the "}" bracket, you will be using the "end;" word. Delphi is a very powerful programming language, but it still keeps its simplicity. It wouldn't hurt if you could take some time to learn it.

Check out these links if you are interested:
www.borland.com - The makers of Delphi
www.torry.net - A great web site where you can find allot of components, code examples and applications for Delphi
www.delphi.about.com - There are some tutorials on this site, and lot's of nice articles (there is a bit more advertising than usual, but it pays off)

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. idpop3 display graphics - 3.67 hr back. (1)
  2. email notifier delphi - 4.75 hr back. (1)
  3. idpop31 receive email delphi - 11.13 hr back. (1)
  4. html form email notification tutorial - 11.82 hr back. (1)
  5. delphi email content part text/html - 13.44 hr back. (1)
  6. delphi simple server - 25.28 hr back. (1)
  7. mail notifier with tidpop3 - 27.44 hr back. (2)
  8. idpop3 graphics - 27.73 hr back. (5)
  9. idpop3 - 28.11 hr back. (1)
  10. delphi try notification outlook style - 29.42 hr back. (1)
  11. send notification to email php button - 32.63 hr back. (1)
  12. how we create edit for delphi like email - 37.20 hr back. (2)
  13. parsing email notification - 37.53 hr back. (1)
  14. delphi outlook unread mails - 37.61 hr back. (1)
Similar Topics

Keywords : delphi, simple, e, mail, notification, system, check, number, e, mails, messages

  1. Cpanel E-mail Management Set-up
    Part 1.1 of My 7 Part Cpanel Tutorial (0)
  2. Cpanel E-mail Management
    Part 1 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 2: Useful Site Management Tools Part 3:
    Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6:
    PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial
    Part 1: E-mail Management In this tutorial I will, in detail explain all of th....
  3. Run Your Own Mail / Radio Server
    SHOUTcast and more (24)
    firstly i want to point out that i did have alot more images that i took for this tutorial but i was
    only aloud to show 15 in this post /sad.gif" style="vertical-align:middle" emoid=":(" border="0"
    alt="sad.gif" /> ill ask for the ammount to be raised then i can add the rest in /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> ok here we go.. Audio
    Streaming Server (Radio) What is a Streaming Audio Server Its an application that will allow you to
    "stream" or send a continuous block of data to a client. In a few words, it will allow....
  4. Php Mail Tutorial
    SENDING MAILS WITH PHP (0)
    Added code tags in BUT not accepting as we already have a mail tut. Pming user regrading code tags,
    credits have not been reduced.... First to send a mail with php we need to design an html form eg
    CODE <form action="mailsend.php" method="post"
    enctype="application/x-www-form-urlencoded" name="form1">    <table
    width="75%" border="0">      <tr>      
     <td><strong><font
    size="4">Subject</font></strong></td>        <td><i....
  5. Php Mail Tutorial
    PHP MAIL TUTOR (2)
    This is mail function for PHP in its simplest form: Code: mail ( string to, string subject,
    string message) The arguments are strings. So that using it might look like: Code: mail (
    “to@emailaddress.com”, “This is my subject line”, “This is my message. \n The \n to the
    left of this text makes a new line”) You can send additional arguments to the function including
    additional headers and parameters. ie: Code: mail ( string to, string subject, string message
    ]) ....
  6. Anonymous Mailing
    how you can send mails anonymously (5)
    Hi ho to all to you who wants to send his friends e-mails without the knowing of them from whom they
    this e-mail /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> TUTORIAL
    REMOVED - OpaQue I don't know who approved this tutorial, but we cannot promote this kind of
    postings! If this happens to work, this is nothing more than contributing to bulk spam or
    exploitation of vulnerable systems. Please consider every aspect before we approve tutorials. ....
  7. E-mail Mailer Script 0.1
    useful for website visitors (4)
    Are you pissed off when you are putting e-mail in your website, you always get spammers? Well,
    here's the solution. Just change the default variables to anything that you like, etc... follow
    the instructions on the script.. Here it is... hope you like it /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> CODE <?php //E-mail Mailer Script 0.1
    by Juan Karlo de Guzman //FOR TRAP17 ONLY... DEMO VERSION... DO NOT DISTRIBUTE
    header("Content-type: text/html; CHARSET=UTF-8");
    $int_rand=mt_rand(1,20); if&#....
  8. Get Rid Of The Banner Ads In Yahoo Mail
    This is a legal way (10)
    Ever wonder those annoying ads or banners appear on the top of the mail page in Yahoo? Do the
    following and hopefully it should get rid of it for you. The step is simple. 1. Login to your mail
    account. 2. Go to the Mail Options at the top right of the screen. 3. Choose Account Information on
    the left. 4. Verify your password again. 5. Click the Edit button just to the right of the word
    Member Information 6. In the General Preferences section, next to the Language & Content: should
    display your Yahoo xx usually U.S. Click on that Yahoo! U.S 7. In the new settings cho....
  9. Simple Parsing Functions
    [Delphi] Tutorial (0)
    Because parsing is such an integral part of string manipulation, I took the time to make a quick and
    simple parse function. For you VBers, Delphi is a derivative of Pascal...it's powerful, simple,
    and (best of all) doesn't need external components (eg: ocx files). Hence the code: CODE
    function TForm1.SimpleParse(MainString, BeginString, EndString: string): string;
    var PosBeginString: integer; PosEndString: integer; begin PosBeginString :=
    Pos(BeginString, MainString) + Length(BeginString); PosEndString ....
  10. Mail Form (php)
    This is a great email form script. (3)
    save this page as formmail.php Code: QUOTE $MailTo = "your email"; $MailSubject
    = "contact"; $MailHeader = "From: $s1"; $MailSent = "Put here the information you
    want to be shown after the message is sent."; if ($s1 == ""){ echo "You did not put your
    name ."; } else { $MailBody = "Name : $s1\n"; } if ($s2 == ""){ echo "You did
    not put your E-Mail ."; } else { $MailBody .= "Email : $s2\n"; } if ($s3 ==
    ""){ } else { $MailBody .= "Message : $s3\n"; } { mail($MailTo....
  11. Delphi Tutorial - Change Your Start Button Caption
    (4)
    How to change your start button caption using Delphi! (By the way, the start button will be
    renamed back to "start" after you restart your computer) Here we go! 1. Create a new project
    in Delphi 2. Add a Button and an Edit box to your form, place them where you want. 3. Double click
    the button to enter the code editor so we can type code for our OnClick event. 4. The code for the
    OnClick event of our button should look like this: CODE procedure
    TForm1.Button1Click(Sender: TObject); var Handle1,Handle2:hwnd; begin
    Handle1:=FindWindo....
  12. [tutorial] Delphi
    Multi-Parsing Function (0)
    I've spent a while trying to create parsing function with Delphi. This language is very useful.
    This tutorial explains how to parse multiple instances of an item in one string. Here is the
    function (which I am actually very proud of): Code: function TForm1.MultiParse(MainString,
    BeginString, EndString: string): TStrings; var PosBeginString, PosEndString, i, LastPos: integer;
    tmpCopy: string; tmpStrings: TStrings; begin tmpStrings := TStringList.Create; LastPos := 0;
    for i := 1 to LastDelimiter(EndString, MainString) do begin PosBeginString := Pos....
  13. Delphi
    Simple Text Parsing Function (1)
    Because parsing is such an integral part of string manipulation, I took the time to make a quick and
    simple parse function. For you VBers, Delphi is a derivative of Pascal...it's powerful, simple,
    and (best of all) doesn't need external component (eg: ocx files). Hence the code: Code:
    function TForm1.SimpleParse(MainString, BeginString, EndString: string): string; var PosBeginString:
    integer; PosEndString: integer; begin PosBeginString := Pos(BeginString, MainString) +
    Length(BeginString); PosEndString := Pos(EndString, MainString); Result := Copy(MainString, ....

    1. Looking for delphi, simple, e, mail, notification, system, check, number, e, mails, messages

Searching Video's for delphi, simple, e, mail, notification, system, check, number, e, mails, messages
advertisement



Delphi - A Simple E-mail Notification System - Check the number of new e-mails messages



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE