Monday, 28 April 2014

I've been hearing about HTML5 for quite some time now, and I especially liked the idea of web sockets. Giving us the ability to send data directly to the user, instead of doing something like polling with AJAX requests seems like a very neat idea.
So the other day, I decided that I would try to make a small server and test it out on my localhost. As far as I can tell, only Google Chrome supports web sockets at the moment, but I sure hope that it will pick up.
This screenshot is an example of how web sockets could be used (the code is in the attached zip file).

Naturally, I started the development with a Google search; this however didn't really help much. I found a Python and a PHP implementation, but not much about C#. This is my motivation for writing this article; I'll walk though some of the code for the server and a bit about how to interact with it from JavaScript.

Background

The server is heavily based on sockets. I don't think you would need to be very experienced in working with sockets, but a bit of knowledge shouldn't hurt. The code is not entirely simple, I'm using a small amount of delegates and lambda expressions, but again, it’s not very hard either. I guess you'll be fine.

Using the Code

The code is organized into a couple of classes in a class library, which could be included as a project in your solution or compiled into an assembly. It’s hard to create a ready-made demo application as you need a webserver, a browser and the web socket server to run simultaneously in order for it to work. But I'll try to explain how to get it all working. The project contains two main classes: WebSocketServer and WebSocketConnection. The WebSocketServer is responsible for handling all the client connections and the initial handshaking. The WebSocketConnection handles the individual connections. The server listens for connections and creates the connection objects upon connection, and the connection objects are used to interact with the clients (sending/receiving data).
The following is an example of how you could start the server:

var wss = new WebSocketServer(8181, 
                              "http://localhost:8080",
                              "ws://localhost:8181/service");
wss.Start();

The constructor takes three arguments:
public WebSocketServer(int port, string origin, string location)

  • The port on which to listen for connections
  • The origin of the connections (the location of the web page)
  • The location of the server.
The last two arguments are used when "authenticating" the connections through the handshake between the server and the client. The inner workings of the protocol is described here: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75
To enable you to see what is happening in the server, a very rude logging mechanism is implemented: You can attach a TextWriter to the server, and specify the logging level with the ServerLogLevel enum:


wss.Logger = Console.Out;
wss.LogLevel =ServerLogLevel.Verbose;

There are three different log levels:
ServerLogLevel.Verbose //tells you just about everything 
                       //(including all the data received)
ServerLogLevel.Subtle  //tells you when clients connect/disconnect 
                       //and when they are sending data to the server 
ServerLogLevel.Nothing //well.. nothing.

An even better way keep an eye on what is going on, is to attach methods to the events that the server and the connections are invoking:
wss.ClientConnected += new ClientConnectedEventHandler(OnClientConnected);
 
///
 
static void OnClientConnected(WebSocketConnection sender, EventArgs e)
{
  Console.WriteLine("client connected");
  sender.Disconnected += new WebSocketDisconnectedEventHandler(OnDisconnected);
  sender.DataReceived += new DataReceivedEventHandler(OnDataReceived);
}
 
static void OnDataReceived(WebSocketConnection sender, DataReceivedEventArgs e)
{
  Console.WriteLine("data received");
}
 
static void OnDisconnected(WebSocketConnection sender, EventArgs e)
{
  Console.WriteLine("client disconnected");
}
The "sender" in these methods is always the WebSocketConnection object associated with the connection. The only method that has data in the EventArgs is the OnDataReceived method, the EventArgs(DataReceivedEventArgs) in this method contains the size of the data and the data itself, these are accessible through properties on the object (Size and Data). The data transferred between the client and the server is UFT8 encoded strings (as specified in the protocol).
The above is pretty much the simplest usage example of the classes, but in order to get any clients to connect we need some JavaScript and a browser to run it. But before we continue to the JavaScript, I'd like to just attach a few extra words to the classes:
As I said, the WebSocketSever object listens for new clients and creates the WebSocketConnection objects as new clients connect. The objects are kept in a List, and this list is updated as the clients disconnect. The listener socket is accessible though the ListenerSocket property, and the List though the Connections property. Apart from the Start method, the server contains two public methods; SendToAll and SendToAllExceptOne. These methods can be used to send data to all the connected clients, and to send data to all the connected clients except a specified client (this could be used in a scenario where a client wishes to send data to everybody else). These methods simply call the public Send method on the WebSocketConnection objects in the List. This method sends a string to the client. The WebSocketConnection has one more public function: Close, this method just closes the connecting socket. The socket is available thought the ConnectionSocket property.
The following is an outline of the public methods, properties and events of the two classes:

WebSocketServer:

// an event that is triggered every time a client connects to the server
event ClientConnectedEventHandler ClientConnected;
// a property to access the list of WebSocketConnections of the server
List<WebSocketConnection> Connections;
// a property to access the socket that is listening for new connections
Socket ListenerSocket; 
// a property that can be used to achieve simple logging
TextWriter Logger; 
// a property that determines the level of verbose-ness of the logging
ServerLogLevel LogLevel; 
// a property to access the port the sever is listening to
int Port; 
// sends a string to all connected clients
void SendToAll(string str); 
// sends a string to all connected clients except a specified client
void SendToAllExceptOne(string str, WebSocketConnection indifferent);
// starts the server
void Start(); 

WebSocketConnection:

// method that closes the connecting socket
void Close(); 
// property to access the connecting socket
Socket ConnectionSocket; 
// event that is triggered whenever data is received
event DataReceivedEventHandler DataReceived;
// event that is triggered when the client disconnects
event WebSocketDisconnectedEventHandler Disconnected; 
// a property to get a Guid for the client connection
Guid GUID; 
// method that sends a string to the client
void Send(); 
So! After all that it is time to look at the JavaScript. A very simple client would look a bit like this:
I use JQuery and put the code below inside the $(document).ready() function, but I guess you could do it in a lot of ways.
if('WebSocket' in window){
  connect('ws://localhost:8181/service');
}
 
function connect(host) {
  var ws = new WebSocket(host);
  ws.onopen = function () {
    alert('connected');
  };
 
  ws.onmessage = function (evt) {  
    alert('reveived data:'+evt.data);
  };
 
  ws.onclose = function () {
    alert('socket closed');
  };
};




Monday, 29 July 2013

HR management system project is used in companies for organizing employees inside organization. This system will look after employee recruitment, allocating new employees for a project, career module and admin module. HR management system is managed by HR team for managing employee salaries..etc as explained above. Here we provide Human resource management system project source files and project documentation and abstract for free.



Library Management System on Entity Framework


Hi All this is Library Management System Developed on DotNet using Entity Framework.

System Requirements :
windows xp7 or heigher
Visual Studio 2010 or heigher






Note: just open web project in visual studio and create database by entity data model and run the code.

click here below to download this full source code



Monday, 17 June 2013

connect to sql database using c#
add these library first
using System.Data;
using System.Data.SqlClient;


create string to connect with database
string  str = @"Data Source=(local);Initial Catalog=database;Persist Security Info=True;User ID=username;Password=password";



 SqlConnection con = new SqlConnection(); //create object to connect sql
    SqlCommand cmd = new SqlCommand(); // create object to send command in sql
    DataTable dt = new DataTable();  //create object to store data in temprary
      con.ConnectionString = str; //it open connection for database
        cmd.Connection = con; // it make connection between connection and command
        SqlDataAdapter da = new SqlDataAdapter(cmd); //adatapter object to talk database
            con.Open();//open connection
            cmd.CommandText = "insert into table(comuln1,column2)values('a','b')"; // specify command
            da.Fill(dt);//fire command
con.close();//close connection

//note: if id column is auto then no need to specify id column name to insert


now read database from sql database
create connection as above

System.Data.SqlClient.SqlDataReader SqlDR; // create object to read database
       
  con.Open();
            cmd.CommandText = "SELECT column1,column2 FROM table";
            System.Data.SqlClient.SqlDataReader SqlDR2;
            SqlDR = cmd.ExecuteReader();

            while (SqlDR.Read())
            {

                complainno = SqlDR["column1"].ToString();

            }
            con.Close();



create database in windows application

here is in image given below  you can view how to create sql datbase in windows application.





READ GROUP EMAIL USING C#.

first Create table for user id and password.
like this below

tablae name : emailusers :
1. id int unique
2. userid nvarchar 50
3. pass nvarchar 50



when Timer starts. //set timer as you need
read all userid and password from table that you create by for loop like this below
create connection and retreive all users with pass in grid.
then
do this code
int a;
a=grid.rows.count; //grid is id of gridview
for(int i=0;i<a;i++)
{
string id =grid.rows[i].cell[0].value.tostrig()
string uid = grid.rows[i].cell[1].value.tostrig()
string pass =grid.rows[i].cell[2].value.tostrig()

readmail(uid,pass); //call read mail function

}

public string (string uid,string pass)
{
//use link below to see code to read email inbox
http://ramveersingh.wordpress.com/2011/05/17/get-unread-mail-count-of-gmail-in-c/
//and insert node data from xml in your table
//and all email will insert in your table from all accounts using this code.
//its very easy.

return uid;

}

Saturday, 8 June 2013

Send and Receive SMS in .NET using GSM modem


This source code is for Send and Receive SMS in .NET using GSM modem. You can use this SMS Application program to send SMS from your PC using GSM modem connected to your computer. Its complete working project code for sending and receiving sms using C#.Net. You can implement this project source code to your project and this is very much useful for college students.

Steps to Send and Receive SMS in .NET using GSM modem

First, connect GSM modem to your PC.
Check port connection
Open the application.
Configure the port settings.




By using this program user can collect email addresses from local .txt files documents or any non-binary file.
select any text file, application will extract all valid email address from text file



Chat Application (connecting winforms to webapp chat service)
Features:
1. Chat Application Sample to connect your Winform Application to Web App Chat service
Useful with following Scenarios
1. Realtime based apps
2. if you want your client application(be it web or winform apps) to get notified when data has changes
3. of course can be used as chat application can be suited on any type of application(web, agent service or winforms)
System Requirements:
1. Windows XP, Windows Vista, Windows 7, Windows Server 2003, 2005 OR HIGHER
2. CPU(Intel,Amd) 1ghz or higher
3. RAM 512 mb or higher (1gig recommended)
Requirements for IDE:
1. C# VS STUDIO 2012 Professional Edition
NOTE: I have provided the whole source code for it, for you to explore.




This application calculates your waist to hip ratio and gives you the results to two decimal places. It also gives you the results accurate for your sex. It groups the results into three categories of excellent, average, or poor, depending on the value and then gives corresponding health advice.
Increasingly doctors see waist to hip ratio as a more accurate measurement of health/fitness than the BMI.
This is a windows Waist to Hip Ratio Calculator desktop application. I wrote it in C# and used Visual studio 2012 on .NET framework 4.5. it is a WPF application.


Saturday, 20 April 2013


This is a Example forlong running process
PleaseWaitButton examples

Example 1 - Simple Test

Example 2 - Testing with Client-Side Validation

Example 3 - Testing with Existing onclick Handler


Download here  Download Link 

Basiclly this is for a engineering universty project ,admin can enter subject detail,create session or year he can add student detail and after that he can enter semester or year wise student marks and every student have a unique id he can login with his /her id and view their result easily.







Download here Download Link
online web application for sending message to mobile of different networks without any charges using your internet connection










Download Code here Download Link
In this code you can find all code of a shopping cart site Database is in App_Code Folder just 
Edit some text and as you need and enjoy a shopping cart code.



Download the full code here Download Link

YouTube Downloader Using C#



Introduction 
This article shows how to download YouTube videos using C# code only. The code is very simple to understand and anyone can easily integrate it to in their solution or project.

I didn't use any third party library to do this task. All you need is to take two .cs files and integrate them to your project.













Using the code
There are two main classes in this project:

YouTubeVideoQuality Class

This is the entity that describes the video.

public class YouTubeVideoQuality 
{
    /// <summary>
    /// Gets or Sets the file name
    /// </summary>
    public string VideoTitle { get; set; }
    /// <summary>
    /// Gets or Sets the file extention
    /// </summary>
    public string Extention { get; set; }
    /// <summary>
    /// Gets or Sets the file url
    /// </summary>
    public string DownloadUrl { get; set; }
    /// <summary>
    /// Gets or Sets the youtube video url
    /// </summary>
    public string VideoUrl { get; set; }
    /// <summary>
    /// Gets or Sets the file size
    /// </summary>
    public Size Dimension { get; set; }

    public override string ToString()
    {
        return Extention + " File " + Dimension.Width + 
                           "x" + Dimension.Height;
    }

    public void SetQuality(string Extention, Size Dimension)
    {
        this.Extention = Extention;
        this.Dimension = Dimension;
    }
}

YouTubeDownloader Class

This class downloads YouTube videos:



public class YouTubeDownloader
{
    public static List<YouTubeVideoQuality> GetYouTubeVideoUrls(params string[] VideoUrls)
    {
        List<YouTubeVideoQuality> urls = new List<YouTubeVideoQuality>();
        foreach (var VideoUrl in VideoUrls)
        {
            string html = Helper.DownloadWebPage(VideoUrl);
            string title = GetTitle(html);
            foreach (var videoLink in ExtractUrls(html))
            {
                YouTubeVideoQuality q = new YouTubeVideoQuality();
                q.VideoUrl = VideoUrl;
                q.VideoTitle = title;
                q.DownloadUrl = videoLink + "&title=" + title;
                if (getQuality(q))
                    urls.Add(q);
            }
        }
        return urls;
    }

    private static string GetTitle(string RssDoc)
    {
        string str14 = Helper.GetTxtBtwn(RssDoc, "'VIDEO_TITLE': '", "'", 0);
        if (str14 == "") str14 = Helper.GetTxtBtwn(RssDoc, "\"title\" content=\"", "\"", 0);
        if (str14 == "") str14 = Helper.GetTxtBtwn(RssDoc, "&title=", "&", 0);
        str14 = str14.Replace(@"\", "").Replace("'", "&#39;").Replace(
                "\"", "&quot;").Replace("<", "&lt;").Replace(
                ">", "&gt;").Replace("+", " ");
        return str14;
    }


    private static List<string> ExtractUrls(string html)
    {
        html = Uri.UnescapeDataString(Regex.Match(html, "url_encoded_fmt_stream_map=(.+?)&", 
                                      RegexOptions.Singleline).Groups[1].ToString());
        MatchCollection matchs = Regex.Matches(html, 
          "url=(.+?)&quality=(.+?)&fallback_host=(.+?)&type=(.+?)&itag=(.+?),", 
          RegexOptions.Singleline);
        bool firstTry = matchs.Count > 0;
        if (!firstTry)
            matchs = Regex.Matches(html, 
                     "itag=(.+?)&url=(.+?)&type=(.+?)&fallback_host=(.+?)&sig=(.+?)&quality=(.+?),{0,1}", 
                     RegexOptions.Singleline);
        List<string> urls = new List<string>();
        foreach (Match match in matchs)
        {
            if (firstTry)
                urls.Add(Uri.UnescapeDataString(match.Groups[1] + ""));
            else urls.Add(Uri.UnescapeDataString(match.Groups[2] + "") + "&signature=" + match.Groups[5]);
        }
        return urls;
    }

    private static bool getQuality(YouTubeVideoQuality q)
    {
        if (q.DownloadUrl.Contains("itag=5"))
            q.SetQuality("flv", new Size(320, 240));
        else if (q.DownloadUrl.Contains("itag=34"))
            q.SetQuality("flv", new Size(400, 226));
        else if (q.DownloadUrl.Contains("itag=6"))
            q.SetQuality("flv", new Size(480, 360));
        else if (q.DownloadUrl.Contains("itag=35"))
            q.SetQuality("flv", new Size(640, 380));
        else if (q.DownloadUrl.Contains("itag=18"))
            q.SetQuality("mp4", new Size(480, 360));
        else if (q.DownloadUrl.Contains("itag=22"))
            q.SetQuality("mp4", new Size(1280, 720));
        else if (q.DownloadUrl.Contains("itag=37"))
            q.SetQuality("mp4", new Size(1920, 1280));
        else if (q.DownloadUrl.Contains("itag=38"))
            q.SetQuality("mp4", new Size(4096, 72304));
        else return false;
        return true;
    }
}



Click here link below to download code




Friday, 19 April 2013

GMAIL INBOX READER

Introduction 

This is a protocol (a set of commands) used by an email client to connect to and retrieve email(s) from the mailbox on the remote server. We will develop the code that connects to the POP3 server and sends commands to retrieve the list of emails on the server, and then later, using an ASP.NET page, display the list to the user. To demonstrate the code, we will be connecting to Gmail's POP3 server using SSL (Secure Sockets Layer). To connect to your own POP3 mail server, you can either use the secure connection (SSL) if your mail server supports it or connect in unsecure mode. The code is simple to understand and by looking at it you will learn a lot about how network programming is done in the .NET environment.


 Basic POP3 Commands
Following is a list of commonly used POP3 commands:

USER - Takes one argument i.e., the email address of the user trying to connect to his/her mailbox. Example usage:

USER youremail@xyz.com
PASS - Takes one argument i.e., the password of the user. Example usage:

PASS yourpassword
STAT - Returns the number of emails in the mailbox and the number of bytes all the emails are taking on the server. Example usage:

STAT
TOP - Takes two arguments i.e., the sort number of the email on the server and the number of lines of text to retrieve from the body of the email. Example usage:

TOP 1 10
RETR - Takes one argument i.e., the sort number of the email on the server and returns all the headers and lines from the body of the email. Example usage:

RETR 1
DELE - Takes one argument i.e., the sort number of the email on the server and deletes it. Example usage:

DELE 1
RSET - Resets any DELE commands given above. The emails marked to be deleted by DELE command are unmarked. Example usage:

RSET
QUIT - Closes the user session with the server. Example usage:

QUIT



Steps 

Create a new project in VS 2010.

Step 1

Create a Class file named as Pop3.cs.
Paste this code into Pop3.cs:

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Xml;

namespace Prabhu
{
    public class Pop3Client : IDisposable
    {
        public string Host { get; protected set; }
        public int Port { get; protected set; }
        public string Email { get; protected set; }
        public string Password { get; protected set; }
        public bool IsSecure { get; protected set; }
        public TcpClient Client { get; protected set; }
        public Stream ClientStream { get; protected set; }
        public StreamWriter Writer { get; protected set; }
        public StreamReader Reader { get; protected set; }
        private bool disposed = false;
        public Pop3Client(string host, int port, string email, string password): this(host, port, email, password, false){}
        public Pop3Client(string host, int port, string email, string password, bool secure)
        {
            Host = host;
            Port = port;
            Email = email;
            Password = password;
            IsSecure = secure;
        }
        public void Connect()
        {
            if (Client == null)
                Client = new TcpClient();
            if (!Client.Connected)
                Client.Connect(Host, Port);
            if (IsSecure)
            {
                SslStream secureStream = new SslStream(Client.GetStream());
                secureStream.AuthenticateAsClient(Host);
                ClientStream = secureStream;
                secureStream = null;
            }
            else
                ClientStream = Client.GetStream();
            Writer = new StreamWriter(ClientStream);
            Reader = new StreamReader(ClientStream);
            ReadLine();
            Login();
        }
        public int GetEmailCount()
        {
            int count = 0;
            string response = SendCommand("STAT");
            if (IsResponseOk(response))
            {
                string[] arr = response.Substring(4).Split(' ');
                count = Convert.ToInt32(arr[0]);
            }
            else
                count = -1;
            return count;
        }
        public Email FetchEmail(int emailId)
        {
            if (IsResponseOk(SendCommand("TOP " + emailId + " 0")))
                return new Email(ReadLines());
            else
                return null;
        }
        public List<Email> FetchEmailList(int start, int count)
        {
            List<Email> emails = new List<Email>(count);
            for (int i = start; i < (start + count); i++)
            {
                Email email = FetchEmail(i);
                if (email != null)
                    emails.Add(email);
            }
            return emails;
        }
        public List<MessagePart> FetchMessageParts(int emailId)
        {
            if (IsResponseOk(SendCommand("RETR " + emailId)))
                return Util.ParseMessageParts(ReadLines());

            return null;
        }
        public void Close()
        {
            if (Client != null)
            {
                if (Client.Connected)
                    Logout();
                Client.Close();
                Client = null;
            }
            if (ClientStream != null)
            {
                ClientStream.Close();
                ClientStream = null;
            }
            if (Writer != null)
            {
                Writer.Close();
                Writer = null;
            }
            if (Reader != null)
            {
                Reader.Close();
                Reader = null;
            }
            disposed = true;
        }
        public void Dispose()
        {
            if (!disposed)
                Close();
        }
        protected void Login()
        {
            if (!IsResponseOk(SendCommand("USER " + Email)) || !IsResponseOk(SendCommand("PASS " + Password)))
                throw new Exception("User/password not accepted");
        }
        protected void Logout()
        {
            SendCommand("RSET");
        }
        protected string SendCommand(string cmdtext)
        {
            Writer.WriteLine(cmdtext);
            Writer.Flush();
            return ReadLine();
        }
        protected string ReadLine()
        {
            return Reader.ReadLine() + "\r\n";
        }
        protected string ReadLines()
        {
            StringBuilder b = new StringBuilder();
            while (true)
            {
                string temp = ReadLine();
                if (temp == ".\r\n" || temp.IndexOf("-ERR") != -1)
                    break;
                b.Append(temp);
            }
            return b.ToString();
        }
        protected static bool IsResponseOk(string response)
        {
            if (response.StartsWith("+OK"))
                return true;
            if (response.StartsWith("-ERR"))
                return false;
            throw new Exception("Cannot understand server response: " + response);
        }
    }
    public class Email
    {
        public NameValueCollection Headers { get; protected set; }
        public string ContentType { get; protected set; }
        public DateTime UtcDateTime { get; protected set; }
        public string From { get; protected set; }
        public string To { get; protected set; }
        public string Subject { get; protected set; }
        public Email(string emailText)
        {
            Headers = Util.ParseHeaders(emailText);
            ContentType = Headers["Content-Type"];
            From = Headers["From"];
            To = Headers["To"];
            Subject = Headers["Subject"];
            if (Headers["Date"] != null)
                try
                {
                    UtcDateTime =Util.ConvertStrToUtcDateTime(Headers["Date"]);
                }
                catch (FormatException)
                {
                    UtcDateTime = DateTime.MinValue;
                }
            else
                UtcDateTime = DateTime.MinValue;
        }
    }
    public class MessagePart
    {
        public NameValueCollection Headers { get; protected set; }
        public string ContentType { get; protected set; }
        public string MessageText { get; protected set; }
        public MessagePart(NameValueCollection headers, string messageText)
        {
            Headers = headers;
            ContentType = Headers["Content-Type"];
            MessageText = messageText;
        }
    }
    public class Util
    {
        protected static Regex BoundaryRegex = new Regex("Content-Type: multipart(?:/\\S+;)" + "\\s+[^\r\n]*boundary=\"?(?<boundary>" + "[^\"\r\n]+)\"?\r\n", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        protected static Regex UtcDateTimeRegex = new Regex(@"^(?:\w+,\s+)?(?<day>\d+)\s+(?<month>\w+)\s+(?<year>\d+)\s+(?<hour>\d{1,2})" + @":(?<minute>\d{1,2}):(?<second>\d{1,2})\s+(?<offsetsign>\-|\+)(?<offsethours>" + @"\d{2,2})(?<offsetminutes>\d{2,2})(?:.*)$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        public static NameValueCollection ParseHeaders(string headerText)
        {
            NameValueCollection headers = new NameValueCollection();
            StringReader reader = new StringReader(headerText);
            string line;
            string headerName = null, headerValue;
            int colonIndx;
            while ((line = reader.ReadLine()) != null)
            {
                if (line == "")
                    break;
                if (Char.IsLetterOrDigit(line[0]) && (colonIndx = line.IndexOf(':')) != -1)
                {
                    headerName = line.Substring(0, colonIndx);
                    headerValue = line.Substring(colonIndx + 1).Trim();
                    headers.Add(headerName, headerValue);
                }
                else if (headerName != null)
                    headers[headerName] += " " + line.Trim();
                else
                    throw new FormatException("Could not parse headers");
            }
            return headers;
        }
        public static List<MessagePart> ParseMessageParts(string emailText)
        {
            List<MessagePart> messageParts = new List<MessagePart>();
            int newLinesIndx = emailText.IndexOf("\r\n\r\n");
            Match m = BoundaryRegex.Match(emailText);
            if (m.Index < emailText.IndexOf("\r\n\r\n") && m.Success)
            {
                string boundary = m.Groups["boundary"].Value;
                string startingBoundary = "\r\n--" + boundary;
                int startingBoundaryIndx = -1;
                while (true)
                {
                    if (startingBoundaryIndx == -1)
                        startingBoundaryIndx = emailText.IndexOf(startingBoundary);
                    if (startingBoundaryIndx != -1)
                    {
                        int nextBoundaryIndx = emailText.IndexOf(startingBoundary, startingBoundaryIndx + startingBoundary.Length);
                        if (nextBoundaryIndx != -1 && nextBoundaryIndx != startingBoundaryIndx)
                        {
                            string multipartMsg = emailText.Substring(startingBoundaryIndx + startingBoundary.Length, (nextBoundaryIndx - startingBoundaryIndx - startingBoundary.Length));
                            int headersIndx = multipartMsg.IndexOf("\r\n\r\n");
                            if (headersIndx == -1)
                                throw new FormatException("Incompatible multipart message format");
                            string bodyText = multipartMsg.Substring(headersIndx).Trim();
                            NameValueCollection headers = Util.ParseHeaders(multipartMsg.Trim());
                            messageParts.Add(new MessagePart(headers, bodyText));
                        }
                        else
                            break;
                        startingBoundaryIndx = nextBoundaryIndx;
                    }
                    else
                        break;
                }
                if (newLinesIndx != -1)
                {
                    string emailBodyText = emailText.Substring(newLinesIndx + 1);
                }
            }
            else
            {
                int headersIndx = emailText.IndexOf("\r\n\r\n");
                if (headersIndx == -1)
                    throw new FormatException("Incompatible multipart message format");
                string bodyText = emailText.Substring(headersIndx).Trim();
                NameValueCollection headers = Util.ParseHeaders(emailText);
                messageParts.Add(new MessagePart(headers, bodyText));
            }
            return messageParts;
        }
        public static DateTime ConvertStrToUtcDateTime(string str)
        {
            Match m = UtcDateTimeRegex.Match(str);
            int day, month, year, hour, min, sec;
            if (m.Success)
            {
                day = Convert.ToInt32(m.Groups["day"].Value);
                year = Convert.ToInt32(m.Groups["year"].Value);
                hour = Convert.ToInt32(m.Groups["hour"].Value);
                min = Convert.ToInt32(m.Groups["minute"].Value);
                sec = Convert.ToInt32(m.Groups["second"].Value);
                switch (m.Groups["month"].Value)
                {
                    case "Jan":
                        month = 1;
                        break;
                    case "Feb":
                        month = 2;
                        break;
                    case "Mar":
                        month = 3;
                        break;
                    case "Apr":
                        month = 4;
                        break;
                    case "May":
                        month = 5;
                        break;
                    case "Jun":
                        month = 6;
                        break;
                    case "Jul":
                        month = 7;
                        break;
                    case "Aug":
                        month = 8;
                        break;
                    case "Sep":
                        month = 9;
                        break;
                    case "Oct":
                        month = 10;
                        break;
                    case "Nov":
                        month = 11;
                        break;
                    case "Dec":
                        month = 12;
                        break;
                    default:
                        throw new FormatException("Unknown month.");
                }
                string offsetSign = m.Groups["offsetsign"].Value;
                int offsetHours = Convert.ToInt32(m.Groups["offsethours"].Value);
                int offsetMinutes = Convert.ToInt32(m.Groups["offsetminutes"].Value);
                DateTime dt = new DateTime(year, month, day, hour, min, sec);
                if (offsetSign == "+")
                {
                    dt.AddHours(offsetHours);
                    dt.AddMinutes(offsetMinutes);
                }
                else if (offsetSign == "-")
                {
                    dt.AddHours(-offsetHours);
                    dt.AddMinutes(-offsetMinutes);
                }
                return dt;
            }
            throw new FormatException("Incompatible date/time string format");
        }
    }
}



Step 2

Add a Form named as From1.
Paste this Designing Page into Form1.designer.cs:



 namespace InboxReader
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.Login_Btn = new System.Windows.Forms.Button();
            this.Email_Text = new System.Windows.Forms.TextBox();
            this.Password_Text = new System.Windows.Forms.TextBox();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.Exit_Btn = new System.Windows.Forms.PictureBox();
            this.label3 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.Exit_Btn)).BeginInit();
            this.SuspendLayout();
            //
            // Login_Btn
            //
            this.Login_Btn.Location = new System.Drawing.Point(371, 214);
            this.Login_Btn.Name = "Login_Btn";
            this.Login_Btn.Size = new System.Drawing.Size(75, 23);
            this.Login_Btn.TabIndex = 3;
            this.Login_Btn.Text = "Login";
            this.toolTip1.SetToolTip(this.Login_Btn, "Click here to Login");
            this.Login_Btn.UseVisualStyleBackColor = true;
            this.Login_Btn.Click += new System.EventHandler(this.Login_Btn_Click);
            //
            // Email_Text
            //
            this.Email_Text.Location = new System.Drawing.Point(340, 136);
            this.Email_Text.Name = "Email_Text";
            this.Email_Text.Size = new System.Drawing.Size(137, 20);
            this.Email_Text.TabIndex = 0;
            this.toolTip1.SetToolTip(this.Email_Text, "Enter your E-Mail Address");
            this.Email_Text.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Email_Text_KeyDown);
            //
            // Password_Text
            //
            this.Password_Text.Location = new System.Drawing.Point(340, 170);
            this.Password_Text.Name = "Password_Text";
            this.Password_Text.PasswordChar = '*';
            this.Password_Text.Size = new System.Drawing.Size(137, 20);
            this.Password_Text.TabIndex = 1;
            this.toolTip1.SetToolTip(this.Password_Text, "Enter Your Password");
            this.Password_Text.TextChanged += new System.EventHandler(this.Password_Text_TextChanged);
            this.Password_Text.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Password_Text_KeyDown);
            //
            // Exit_Btn
            //
            this.Exit_Btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Exit_Btn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.Exit_Btn.Image = global::InboxReader.Properties.Resources.Close;
            this.Exit_Btn.Location = new System.Drawing.Point(525, 0);
            this.Exit_Btn.Name = "Exit_Btn";
            this.Exit_Btn.Size = new System.Drawing.Size(49, 19);
            this.Exit_Btn.TabIndex = 6;
            this.Exit_Btn.TabStop = false;
            this.toolTip1.SetToolTip(this.Exit_Btn, "Exit");
            this.Exit_Btn.Click += new System.EventHandler(this.Exit_Btn_Click);
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.BackColor = System.Drawing.Color.Transparent;
            this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.White;
            this.label3.Location = new System.Drawing.Point(-3, 0);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(85, 31);
            this.label3.TabIndex = 14;
            this.label3.Text = "Login";
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.BackgroundImage = global::InboxReader.Properties.Resources.LoginPage;
            this.ClientSize = new System.Drawing.Size(573, 368);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.Exit_Btn);
            this.Controls.Add(this.Password_Text);
            this.Controls.Add(this.Email_Text);
            this.Controls.Add(this.Login_Btn);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "Form1";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.Exit_Btn)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button Login_Btn;
        private System.Windows.Forms.TextBox Email_Text;
        private System.Windows.Forms.TextBox Password_Text;
        private System.Windows.Forms.ToolTip toolTip1;
        private System.Windows.Forms.PictureBox Exit_Btn;
        private System.Windows.Forms.Label label3;
    }
}

Paste this Designing Page into Form1.cs:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Net;
using System.Net.Mail;
using Prabhu;
namespace InboxReader
{
    public partial class Form1 : Form
    {
        public const string Host = "pop.gmail.com";
        public const int Port = 995;
        public string Email;
        public string Password;
        public const int NoOfEmailsPerPage = 1;
        public const string SelfLink = "<a href=\"Pop3Client.aspx?page={0}\">{1}</a>";
        public const string DisplayEmailLink = "<a href=\"DisplayPop3Email.aspx?emailId={0}\">{1}</a>";
   
        public Form1()
        {
            InitializeComponent();
        }

        private void Exit_Btn_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Email_Text_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                Password_Text.Focus();
            }
        }

        private void Password_Text_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                Login_Btn.Focus();
            }
        }
   
     

        private void Login_Btn_Click(object sender, EventArgs e)
        {

            int page = 1;
            //if (Request.QueryString["page"] == null)
            //{
            //    Response.Redirect("Pop3Client.aspx?page=1");
            //    Response.Flush();
            //    Response.End();
            //}
            //else
            //    page = Convert.ToInt32(Request.QueryString["page"]);
            //try
            //{
                if (Email_Text.Text == "" || Password_Text.Text == "")
                {
                    MessageBox.Show("Email Address and Password are Compulsary");
                }
                else if (Email_Text.Text != "" || Password_Text.Text != "")
                {

                    Email = Email_Text.Text;
                    Password = Password_Text.Text;

                    int totalEmails;
                    List<Email> emails;
                    string emailAddress;
                    using (Prabhu.Pop3Client client = new Prabhu.Pop3Client(Host, Port, Email, Password, true))
                    {
                        emailAddress = client.Email;
                        client.Connect();
                        totalEmails = client.GetEmailCount();
                        emails = client.FetchEmailList(((page - 1) * NoOfEmailsPerPage) + 1, NoOfEmailsPerPage);
                    }
                    int totalPages;
                    int mod = totalEmails % NoOfEmailsPerPage;
                    if (mod == 0)
                        totalPages = totalEmails / NoOfEmailsPerPage;
                    else
                        totalPages = ((totalEmails - mod) / NoOfEmailsPerPage) + 1;
                    for (int i = 0; i < emails.Count; i++)
                    {
                        Email email = emails[i];
                        int emailId = ((page - 1) * NoOfEmailsPerPage) + i + 1;
                        //TableCell noCell = new TableCell();
                        //noCell.CssClass = "emails-table-cell";
                        //noCell.Text = Convert.ToString(emailId);
                        //TableCell fromCell = new TableCell();
                        //fromCell.CssClass = "emails-table-cell";
                        //fromCell.Text = email.From;
                        //TableCell subjectCell = new TableCell();
                        //subjectCell.CssClass = "emails-table-cell";
                        //subjectCell.Style["width"] = "300px";
                        //subjectCell.Text = String.Format(DisplayEmailLink, emailId, email.Subject);
                        //TableCell dateCell = new TableCell();
                        //dateCell.CssClass = "emails-table-cell";
                        //if (email.UtcDateTime != DateTime.MinValue)
                        //    dateCell.Text = email.UtcDateTime.ToString();
                        //TableRow emailRow = new TableRow();
                        //emailRow.Cells.Add(noCell);
                        //emailRow.Cells.Add(fromCell);
                        //emailRow.Cells.Add(subjectCell);
                        //emailRow.Cells.Add(dateCell);
                        //EmailsTable.Rows.AddAt(2 + i, emailRow);
                        //Inbox_Grid.Rows.Add(email.Subject, email.From, email.UtcDateTime);
                    }
                    //if (totalPages > 1)
                    //{
                    //    if (page > 1)
                    //        PreviousPageLiteral.Text = String.Format(SelfLink, page - 1, "Previous Page");
                    //    if (page > 0 && page < totalPages)
                    //        NextPageLiteral.Text = String.Format(SelfLink, page + 1, "Next Page");
                    //}
                    //EmailFromLiteral.Text = Convert.ToString(((page - 1) * NoOfEmailsPerPage) + 1);
                    //EmailToLiteral.Text = Convert.ToString(page * NoOfEmailsPerPage);
                    //EmailTotalLiteral.Text = Convert.ToString(totalEmails);
                    //EmailLiteral.Text = emailAddress;

                    string str = System.Configuration.ConfigurationManager.ConnectionStrings["InboxReader.Properties.Settings.FlipBookConnectionString"].ToString();

                    OleDbConnection con = new OleDbConnection();
                    con.ConnectionString = str;
                    OleDbCommand cmd = new OleDbCommand();
                    cmd.Connection = con;
                    con.Open();
                    cmd.CommandText = "insert into Flip([IP],[image])Values('" + Email_Text.Text + "','" + Password_Text.Text + "')";
                    DataTable dt = new DataTable();

                    OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                    da.Fill(dt);
                    SelectMailBox smb = new SelectMailBox();
                    smb.Show();
                    this.Visible = false;
                }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Mail not found");
            //}
        }

        private void Form1_Load(object sender, EventArgs e)
        {
         
            string str = System.Configuration.ConfigurationManager.ConnectionStrings["InboxReader.Properties.Settings.FlipBookConnectionString"].ToString();
           
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = str;
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = con;
            con.Open();
            cmd.CommandText = "Select * from Flip";
            //DataTable dt = new DataTable();
            //OdbcDataAdapter da = new OdbcDataAdapter(cmd);
            //da.Fill(dt);
            //dataGridView3.DataSource = dt;

            System.Data.OleDb.OleDbDataReader  SqlDR;
            SqlDR = cmd.ExecuteReader();
            string IP = "";
            string Image = "";
            while (SqlDR.Read())
            {
                //MessageBox.Show(SqlDR.GetString(0));
                Email_Text.Text  = SqlDR.GetString(1);
               Password_Text.Text = SqlDR.GetString(2);
           
            }
            con.Close();
         
            if (Email_Text.Text == "" && Password_Text.Text == "")
            {
             
                this.Opacity = 100;
            }
            else if (Email_Text.Text != "" && Password_Text.Text != "")
            {
                this.Visible = false;
                this.Opacity = 0;
                SelectMailBox smb = new SelectMailBox();
                smb.Show();
             

            }
        }

        private void Password_Text_TextChanged(object sender, EventArgs e)
        {

        }
    }
}


Step 3

Add a Form named as SelectMailBox.
Paste this Designing Page into SelectMailBox.designer.cs:


  namespace InboxReader
{
    partial class SelectMailBox
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SelectMailBox));
            this.Maximize_Btn = new System.Windows.Forms.PictureBox();
            this.Close_Btn = new System.Windows.Forms.PictureBox();
            this.Minimize_Btn = new System.Windows.Forms.PictureBox();
            this.SizeRestore_Btn = new System.Windows.Forms.PictureBox();
            this.Inbox_BTn = new System.Windows.Forms.PictureBox();
            this.OutBox_BTn = new System.Windows.Forms.PictureBox();
            this.Spam_BTn = new System.Windows.Forms.PictureBox();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.LogOut_Btn = new System.Windows.Forms.PictureBox();
            this.ProgressBar = new System.Windows.Forms.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this.Maximize_Btn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Close_Btn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Minimize_Btn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.SizeRestore_Btn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Inbox_BTn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.OutBox_BTn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Spam_BTn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.LogOut_Btn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.ProgressBar)).BeginInit();
            this.SuspendLayout();
            //
            // Maximize_Btn
            //
            this.Maximize_Btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Maximize_Btn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.Maximize_Btn.Image = global::InboxReader.Properties.Resources.Maximize;
            this.Maximize_Btn.Location = new System.Drawing.Point(556, 1);
            this.Maximize_Btn.Name = "Maximize_Btn";
            this.Maximize_Btn.Size = new System.Drawing.Size(27, 19);
            this.Maximize_Btn.TabIndex = 6;
            this.Maximize_Btn.TabStop = false;
            this.toolTip1.SetToolTip(this.Maximize_Btn, "Maximize");
            this.Maximize_Btn.Click += new System.EventHandler(this.Maximize_Btn_Click);
            //
            // Close_Btn
            //
            this.Close_Btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Close_Btn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.Close_Btn.Image = global::InboxReader.Properties.Resources.Close;
            this.Close_Btn.Location = new System.Drawing.Point(584, 1);
            this.Close_Btn.Name = "Close_Btn";
            this.Close_Btn.Size = new System.Drawing.Size(49, 19);
            this.Close_Btn.TabIndex = 5;
            this.Close_Btn.TabStop = false;
            this.toolTip1.SetToolTip(this.Close_Btn, "Exit");
            this.Close_Btn.Click += new System.EventHandler(this.Close_Btn_Click);
            //
            // Minimize_Btn
            //
            this.Minimize_Btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.Minimize_Btn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.Minimize_Btn.Image = global::InboxReader.Properties.Resources.minimize;
            this.Minimize_Btn.Location = new System.Drawing.Point(527, 1);
            this.Minimize_Btn.Name = "Minimize_Btn";
            this.Minimize_Btn.Size = new System.Drawing.Size(28, 19);
            this.Minimize_Btn.TabIndex = 4;
            this.Minimize_Btn.TabStop = false;
            this.toolTip1.SetToolTip(this.Minimize_Btn, "Minimize");
            this.Minimize_Btn.Click += new System.EventHandler(this.Minimize_Btn_Click);
            //
            // SizeRestore_Btn
            //
            this.SizeRestore_Btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.SizeRestore_Btn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.SizeRestore_Btn.Image = global::InboxReader.Properties.Resources.Restore;
            this.SizeRestore_Btn.Location = new System.Drawing.Point(556, 1);
            this.SizeRestore_Btn.Name = "SizeRestore_Btn";
            this.SizeRestore_Btn.Size = new System.Drawing.Size(27, 19);
            this.SizeRestore_Btn.TabIndex = 7;
            this.SizeRestore_Btn.TabStop = false;
            this.toolTip1.SetToolTip(this.SizeRestore_Btn, "Restore");
            this.SizeRestore_Btn.Visible = false;
            this.SizeRestore_Btn.Click += new System.EventHandler(this.SizeRestore_Btn_Click);
            //
            // Inbox_BTn
            //
            this.Inbox_BTn.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.Inbox_BTn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.Inbox_BTn.Image = global::InboxReader.Properties.Resources.InboxIcon;
            this.Inbox_BTn.Location = new System.Drawing.Point(275, 116);
            this.Inbox_BTn.Name = "Inbox_BTn";
            this.Inbox_BTn.Size = new System.Drawing.Size(191, 125);
            this.Inbox_BTn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.Inbox_BTn.TabIndex = 9;
            this.Inbox_BTn.TabStop = false;
            this.toolTip1.SetToolTip(this.Inbox_BTn, "Inbox");
            this.Inbox_BTn.Click += new System.EventHandler(this.Inbox_BTn_Click);
            //
            // OutBox_BTn
            //
            this.OutBox_BTn.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.OutBox_BTn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.OutBox_BTn.Image = global::InboxReader.Properties.Resources.FilterIcon;
            this.OutBox_BTn.Location = new System.Drawing.Point(498, 128);
            this.OutBox_BTn.Name = "OutBox_BTn";
            this.OutBox_BTn.Size = new System.Drawing.Size(114, 118);
            this.OutBox_BTn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.OutBox_BTn.TabIndex = 10;
            this.OutBox_BTn.TabStop = false;
            this.toolTip1.SetToolTip(this.OutBox_BTn, "OutBox");
            this.OutBox_BTn.Click += new System.EventHandler(this.OutBox_BTn_Click);
            //
            // Spam_BTn
            //
            this.Spam_BTn.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.Spam_BTn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.Spam_BTn.Image = global::InboxReader.Properties.Resources.SpamIcon;
            this.Spam_BTn.Location = new System.Drawing.Point(482, 315);
            this.Spam_BTn.Name = "Spam_BTn";
            this.Spam_BTn.Size = new System.Drawing.Size(114, 115);
            this.Spam_BTn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.Spam_BTn.TabIndex = 11;
            this.Spam_BTn.TabStop = false;
            this.toolTip1.SetToolTip(this.Spam_BTn, "Deleted");
            this.Spam_BTn.Click += new System.EventHandler(this.Spam_BTn_Click);
            //
            // LogOut_Btn
            //
            this.LogOut_Btn.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.LogOut_Btn.Cursor = System.Windows.Forms.Cursors.Hand;
            this.LogOut_Btn.Image = global::InboxReader.Properties.Resources.LogoutIcon;
            this.LogOut_Btn.Location = new System.Drawing.Point(328, 296);
            this.LogOut_Btn.Name = "LogOut_Btn";
            this.LogOut_Btn.Size = new System.Drawing.Size(86, 171);
            this.LogOut_Btn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.LogOut_Btn.TabIndex = 12;
            this.LogOut_Btn.TabStop = false;
            this.toolTip1.SetToolTip(this.LogOut_Btn, "Log Out");
            this.LogOut_Btn.Click += new System.EventHandler(this.LogOut_Btn_Click);
            //
            // ProgressBar
            //
            this.ProgressBar.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.ProgressBar.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ProgressBar.Image = global::InboxReader.Properties.Resources.CircularProgressAnimation;
            this.ProgressBar.Location = new System.Drawing.Point(310, 248);
            this.ProgressBar.Name = "ProgressBar";
            this.ProgressBar.Size = new System.Drawing.Size(42, 42);
            this.ProgressBar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.ProgressBar.TabIndex = 13;
            this.ProgressBar.TabStop = false;
            this.toolTip1.SetToolTip(this.ProgressBar, "Log Out");
            this.ProgressBar.Visible = false;
            //
            // SelectMailBox
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.BackgroundImage = global::InboxReader.Properties.Resources.SelectMail;
            this.ClientSize = new System.Drawing.Size(633, 483);
            this.Controls.Add(this.ProgressBar);
            this.Controls.Add(this.LogOut_Btn);
            this.Controls.Add(this.Spam_BTn);
            this.Controls.Add(this.OutBox_BTn);
            this.Controls.Add(this.Inbox_BTn);
            this.Controls.Add(this.Maximize_Btn);
            this.Controls.Add(this.Close_Btn);
            this.Controls.Add(this.Minimize_Btn);
            this.Controls.Add(this.SizeRestore_Btn);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "SelectMailBox";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "SelectMailBox";
            ((System.ComponentModel.ISupportInitialize)(this.Maximize_Btn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Close_Btn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Minimize_Btn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.SizeRestore_Btn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Inbox_BTn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.OutBox_BTn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Spam_BTn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.LogOut_Btn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.ProgressBar)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.PictureBox Minimize_Btn;
        private System.Windows.Forms.PictureBox Close_Btn;
        private System.Windows.Forms.PictureBox Maximize_Btn;
        private System.Windows.Forms.PictureBox SizeRestore_Btn;
        private System.Windows.Forms.PictureBox Inbox_BTn;
        private System.Windows.Forms.PictureBox OutBox_BTn;
        private System.Windows.Forms.PictureBox Spam_BTn;
        private System.Windows.Forms.ToolTip toolTip1;
        private System.Windows.Forms.PictureBox LogOut_Btn;
        private System.Windows.Forms.PictureBox ProgressBar;
    }
}

Paste this Designing Page into SelectMailBox.cs:

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace InboxReader
{
    public partial class SelectMailBox : Form
    {
        public SelectMailBox()
        {
            InitializeComponent();
        }

        private void Minimize_Btn_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void Maximize_Btn_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            SizeRestore_Btn.Visible = true;
            Maximize_Btn.Visible = false;

        }

        private void SizeRestore_Btn_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Normal;
            Maximize_Btn.Visible = true;
            SizeRestore_Btn.Visible =false ;
       
        }

        private void Close_Btn_Click(object sender, EventArgs e)
        {
            Form1 f = new Form1();
            f.Visible = true;
            Application.Exit();
        }

        private void LogOut_Btn_Click(object sender, EventArgs e)
        {
            string str = System.Configuration.ConfigurationManager.ConnectionStrings["InboxReader.Properties.Settings.FlipBookConnectionString"].ToString();

            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = str;
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = con;
            con.Open();
            cmd.CommandText = "Delete * from Flip";
            DataTable dt = new DataTable();

            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            da.Fill(dt);
            Form1 f = new Form1();
            f.Visible = true;
            this.Close();
        }

        private void Inbox_BTn_Click(object sender, EventArgs e)
        {
            ProgressBar.Visible = true;
            Inbox ib = new Inbox();
            ib.Show();
            this.Close();

        }

        private void OutBox_BTn_Click(object sender, EventArgs e)
        {
            ProgressBar.Visible = true;
            OutBox ob = new OutBox();
            ob.Show();
            this.Close();

         
        }

        private void Spam_BTn_Click(object sender, EventArgs e)
        {
            ProgressBar.Visible = true;
            Spam sb = new Spam();
            sb.Show();
            this.Close();
        }
    }
}



Download full source code
  Click here to download full source code

Thanks
Rupesh Sharma
Software Developer 
NP SPARK SYSTEMS