Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to read email from gmail using asp.net
Posted

Check this out. Using Gmail Account to Send Emails With Attachment[^], but that is for sending.

See IMAP Client library using C#[^] and How to Access Emails Using the IMAP Protocol[^] for reading email via IMAP interface.
 
Share this answer
 
v2
Comments
thatraja 2-Jun-11 12:13pm    
It's a good Tip/Trick, 5!
Kim Togo 4-Jun-11 1:44am    
Thanks
Hi I a couple weeks ago I had the same problem. I've solved it by using mail component by http://www.lesnikowski.com/[^]. It is not free but not so expensive.

Regards
Robert
 
Share this answer
 
You are able to access your gmail email using outlook
if not then login to www.gmail.com click on settings => pop => check to access email outside gmail web client


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net.NetworkInformation;
using System.Net.Security;
using System.Net.Sockets;
protected void Button9_Click(object sender, EventArgs e)
{
try
{
// create an instance of TcpClient 
TcpClient tcpclient = new TcpClient();     
// HOST NAME POP SERVER and gmail uses port number 995 for POP 
tcpclient.Connect("pop.gmail.com", 995); 
// This is Secure Stream // opened the connection between client and POP Server
System.Net.Security.SslStream sslstream = new SslStream(tcpclient.GetStream());
// authenticate as client  
 sslstream.AuthenticateAsClient("pop.gmail.com");
//bool flag = sslstream.IsAuthenticated;   // check flag
// Asssigned the writer to stream 
System.IO.StreamWriter sw = new StreamWriter(sslstream);
// Assigned reader to stream
System.IO.StreamReader reader = new StreamReader(sslstream);
// refer POP rfc command, there very few around 6-9 command
sw.WriteLine("USER your_gmail_user_name@gmail.com");
// sent to server
sw.Flush();
sw.WriteLine("PASS your_gmail_password");
sw.Flush();
// this will retrive your first email
sw.WriteLine("RETR 1");
sw.Flush();
// close the connection
sw.WriteLine("Quit ");
sw.Flush();
string str = string.Empty;
string strTemp = string.Empty;
while ((strTemp = reader.ReadLine()) != null)
{
// find the . character in line
if (strTemp == ".")
{
break;
}
if (strTemp.IndexOf("-ERR") != -1)
{
break;
}
str += strTemp;
}
Response.Write(str);
Response.Write("<BR>" + "Congratulation.. ....!!! You read your first gmail email ");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
 
Share this answer
 
Comments
Member 11054816 1-Oct-14 1:02am    
I have more than 10000 mail in inbox.In this code i can read only 317.so please help me that how can i read the all mail from gamil account.
[url=http://www.smartyazilim.com/]smart yazılım[/url],[url=http://www.smartyazilim.com/web-tasarim-web-yazilim_1_.aspx]web tasarım[/url],[url=http://www.smartyazilim.com/web-yazilim-web-yazilim_2_.aspx]web yazılım[/url],[url=http://www.smartyazilim.com/e-ticaret-web-yazilim_4_.aspx]e-ticaret[/url],[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır portal[/url],[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır portallar[/url],[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır e-ticaret portalı[/url],[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır e-ticaret sitesi[/url],[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır emlak portalı[/url],
[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır ilan sistemi sitesi[/url],
[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır ilan sistemi portalı[/url],
[url=http://www.smartyazilim.com/hazir-portallar-web-yazilim_7_.aspx]hazır emlak portalı[/url],
[url=http://www.eraykoltukmobilya.com/]eray döşeme[/url],[url=http://www.eraykoltukmobilya.com/]eray koltuk mobilya[/url],[url=http://www.eraykoltukmobilya.com/]eray koltuk döşeme[/url],[url=http://www.eraykoltukmobilya.com/]eray tekli koltuk[/url],
[url=http://www.eraykoltukmobilya.com/]koltuk döşeme[/url],[url=http://www.eraykoltukmobilya.com/]koltuk tamiri[/url],
[url=http://www.eraykoltukmobilya.com/]koltuk tamiratı[/url],
[url=http://www.eraykoltukmobilya.com/]eray döşeme[/url],[url=http://www.silvercorap.com/]silver çorap[/url],[url=http://www.silvercorap.com/]gümüş çorap[/url],[url=http://www.silvercorap.com/gumus-coraplar-kategorisi_1_.aspx]silver çorap[/url],[url=http://www.silvercorap.com/mantar-silver-corap-urunu_14_.aspx]mantara karşı gümüş çorap[/url],[url=http://www.silvercorap.com/mantar-silver-corap-urunu_14_.aspx]mantara karşı silver çorap[/url],[url=http://www.silvercorap.com/dinlendirici-gumus-patik-corap-urunu_11_.aspx]dinlendirici gümüş çorap[/url],[url=http://www.silvercorap.com/dinlendirici-gumus-patik-corap-urunu_11_.aspx]dinlendirici silver çorap[/url],[url=http://www.silvercorap.com/antibakteriyel-gumus-corap-urunu_2_.aspx]antibakteriyel gümüş çorap[/url],[url=http://www.silvercorap.com/antibakteriyel-gumus-corap-urunu_2_.aspx]antibakteriyel silver çorap[/url],<a href="http://www.smartyazilim.com">Smart Yazılım</a>
 
Share this answer
 
Comments
HardikPatel.SE 30-Jan-14 4:49am    
?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900