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");
}
}
}
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;
}
}
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)
{
}
}
}
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();
}
}
}
Thanks
Rupesh Sharma
Software Developer
NP SPARK SYSTEMS
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:

{
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.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:

{
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
Rupesh Sharma
Software Developer
NP SPARK SYSTEMS
thanx...
ReplyDeleteI found this useful Rupesh . Cool App
ReplyDelete-Sameer
www.programmingposts.blogspot.com
I want to read Emails form only inbox not from sent box. I am using pop3client STAT Command to read a email and it is reading both inbox and sent box emails. Is it possible to read only inbox emails ?
ReplyDelete