Day : Feb, 28, 2013

Send & Receive E-mails from E-mail server using VB .net Update #2.

Today's update is about :

Retrieving the number of E-mails from your [Inbox] into a [TextBox] control.

The number of e-mails would be found in the response of the [STAT] command returned from the POP3 server, but it varies from server to server, (I.e. the gmail server returns the wrong number in the first time you try to retrieve the number of e-mails), why?!
because you need to download the E-mails first so the buffer could recognize the actual amount of messages number returned from the server, but it works fine with hotmail (pop3.live.com).

Applying to the previous code update (1), now we will add a [TextBox] called [MsgCount] and a lable[Label1] called [Number of E-mails] , so according to the previous update (1) we managed to retrieve the [STAT] response from the POP3 server of the Gmail.com (pop.gmail.com) and the number of messages is a part of the string received at the buttom of the [ListBox] we used to list our responses, it is something like this :

+OK 0 0 or +OK 184 1808329 , what does it mean?!

It means that there is (184) messages in my Inbox and the size of them in bytes is (1808329 Bytes), so to to split the number of messages i use this line of code in the Login Sub:

You would receive [ +OK 0 0 ] If you setup your Gmail.com inbox settings to [ Enable POP for mail that arrives from now on] in case no new e-mails arrived, so naturally you would get 0 e-mails, but if you want to get the whole e-mails count you may want to consider using settings [ Enable POP for all mail (even mail that's already been downloaded) ] and that would give you the whole e-mails since you created your account. As long as Hotmail.com doesn't care about that, so it doesn't matter, you still will get the same number of e-mails that is in your Inbox currently.

So, the new code will be like this, instead of the old one in Update (1) :

Notice the last block of code represents the new update (2) to retrieve the number of messages and display it in the [TextBox] .


Update

Update (3) - Retrieving\Getting list of E-mail messages from Inbox and dressing up the application.

Back


All Rights Reserved to the Developer evry1falls