Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, June 22, 2010 8:01 AM | 2 votes
Hi everyone ;
I want to read my hotmail or gmail inbox with a desktop application like as Outlook.
I want read my inbox and show it in datagridview.
How can ı do this.Can anyone help me ?
All replies (8)
Tuesday, June 22, 2010 8:37 AM ✅Answered
May be these links can help you:
http://www.csharphelp.com/2006/06/c-mail-reader/
http://www.eggheadcafe.com/community/aspnet/2/10054366/how-to-read-mail-from-pop3-inbox-using-c.aspx
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
Wednesday, June 23, 2010 8:29 AM ✅Answered | 1 vote
Hi omur gok,
Welcome to MSDN forums! I'm glad to see your active participation and discussion in MSDN forums. Based on my understanding your issue was wanted to read the emails using C#. If it's true I think socket pop3 was a good choice to solve your issue. For exmaple:
using System.IO;
using System.Net.NetworkInformation;
using System.Net.Security;
using System.Net.Sockets;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// create an instance of TcpClient
TcpClient tcpclient = new TcpClient();
tcpclient.Connect("pop3.live.com", 995);
System.Net.Security.SslStream sslstream = new SslStream(tcpclient.GetStream());
sslstream.AuthenticateAsClient("pop3.live.com");
StreamWriter sw = new StreamWriter(sslstream);
System.IO.StreamReader reader = new StreamReader(sslstream);
sw.WriteLine("USER [email protected]"); sw.Flush();
<br/> sw.WriteLine("PASS xxxx****"); sw.Flush();
sw.WriteLine("RETR 1");
sw.Flush();
sw.WriteLine("Quit ");
sw.Flush();
string str = string.Empty;
string strTemp = string.Empty;
while ((strTemp = reader.ReadLine()) != null){
if (".".Equals(strTemp)){
break;
}
if (strTemp.IndexOf("-ERR") != -1){
break;
}
str += strTemp;
}
Response.Write(str);
reader.Close();
sw.Close();
tcpclient.Close(); // close the connection
}
}
Hope this will help you! If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.
Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.
Best Regards,
Yan Jun
Microsoft Online Community Support
Tuesday, June 22, 2010 9:05 AM
Thank u I will try
Wednesday, June 23, 2010 10:09 AM
Hi Yan Jun
thank u for your post.I try your code but ı get runtime error when tcpclient connecting.
System.Net.Sockets.SocketException was unhandled
Message=There is no known machine
Source=System
ErrorCode=11001
NativeErrorCode=11001
StackTrace:
at System.Net.Dns.GetAddrInfo(String name)
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
at WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Extgok\My Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:line 24
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication2.Program.Main() in C:\Documents and Settings\Extgok\My Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
What must ı do .I want to read my email from my hotmail account...
Wednesday, June 23, 2010 5:17 PM
Hi Yan Jun help me ı read my hotmail mailbox with your code on internet connection which has no proxy.
but ı want to show my email like in hotmail.for example ı want to show ıt in a datagridview in windows form and when ı clicked name of a email.This email body must shown.
How can ı do this.Help me plzzzz....
Tuesday, June 29, 2010 11:27 AM
Hi omur,
I'm sorry for delay. Here's full sample please refer to http://www.revenmerchantservices.com/page/read-gmail.aspx
Hope this will help you!
If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.
Best Regards,
Yan Jun
Microsoft Online Community Support
Tuesday, December 7, 2010 1:00 PM
Hi omur gok,
Welcome to MSDN forums! I'm glad to see your active participation and discussion in MSDN forums. Based on my understanding your issue was wanted to read the emails using C#. If it's true I think socket pop3 was a good choice to solve your issue. For exmaple:
using System.IO; using System.Net.NetworkInformation; using System.Net.Security; using System.Net.Sockets; public partial class Default3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // create an instance of TcpClient TcpClient tcpclient = new TcpClient(); tcpclient.Connect("pop3.live.com", 995); System.Net.Security.SslStream sslstream = new SslStream(tcpclient.GetStream()); sslstream.AuthenticateAsClient("pop3.live.com"); StreamWriter sw = new StreamWriter(sslstream); System.IO.StreamReader reader = new StreamReader(sslstream); sw.WriteLine("USER [email protected]"); sw.Flush(); <br/> sw.WriteLine("PASS xxxx****"); sw.Flush(); sw.WriteLine("RETR 1"); sw.Flush(); sw.WriteLine("Quit "); sw.Flush(); string str = string.Empty; string strTemp = string.Empty; while ((strTemp = reader.ReadLine()) != null){ if (".".Equals(strTemp)){ break; } if (strTemp.IndexOf("-ERR") != -1){ break; } str += strTemp; } Response.Write(str); reader.Close(); sw.Close(); tcpclient.Close(); // close the connection } }
Hope this will help you! If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.
Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.
Best Regards,
Yan Jun
Microsoft Online Community Support
I have two errors:
Error 1: The type or namespace name 'UI' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) C:\Users\Niels\Documents\Browser\ControlsTest\ControlsTest\ConnectToMail.cs 12 49 ControlsTest.
Error 2: The name 'Response' does not exist in the current context C:\Users\Niels\Documents\Browser\ControlsTest\ControlsTest\ConnectToMail.cs 40 2 ControlsTest
Can someone help me?
Tuesday, July 12, 2011 10:00 AM
Retrieves email but "HOW" am I suppose to read it? The message body is a bunch of what appears to be random characters. I know it's not just a bunch of random characters but some code that needs to be parsed and converted. How do I go about doing this?
Thanks in advance,
Donald
donald