Home » .Net FrameworkRSS

Open my gmail Inbox

Hi friends,
I want to open my gmail inbox by c# code.I will give my gmail username and password.It should open My Inbox automatically.How may i do it?Thanks in advance.
 

8 Answers Found

 

Answer 1

Use System.Net.SmtpClient. 
 

Answer 2

Hi friends,
Can u explain in detail?Thanks in advance.
 

Answer 3

Hi,
I'm not exactly sure what do you mean by "open my gmail  inbox in c#". If it means "find list of messages in the inbox, download them and read them" you have several options.

The easiest one is using one of protocols designed for reading email such as POP3 and IMAP. Both are supported by Gmail. Before using them make sure that they are enabled: Go to gmail, click "Settings", click "Forwarding and POP/IMAP" and check the form.

The .NET Framework does not have a built-in support for POP3 or IMAP. You have to find a third party component. The Gmail requires an encrypted communication channel, which means that you need a component which supports POP3/SSL or IMAP/SSL. There are at least three free POP3 libraries at codeproject.com but I'm not sure whether they support POP3/SSL.

You may find a few commercial email components for POP3 and IMAP. Following code  is taken from a blogpost "HOWTO: Download emails from a GMail account in C# " which uses Rebex Secure Mail for .NET

using Rebex.Mail;
using Rebex.Net;
...
// -----------------
// create the POP3 client
// -----------------
Pop3 client = new Pop3();
try
{
   // -----------------
   // connect and login
   // -----------------
   
   // Connect securely using explicit SSL. 
   // Use the third argument to specify additional SSL parameters. 
   Console.WriteLine("Connecting to the POP3 server...");
   client.Connect("pop.gmail.com", 995, null, Pop3Security.Implicit);
   
   // login and password
   client.Login(email, password);
   
   // get the number of messages
   Console.WriteLine("{0} messages found.", client.GetMessageCount());
   
   // -----------------
   // list messages
   // -----------------
   
   // list all messages
   Pop3MessageCollection messages = 
      client.GetMessageList(Pop3ListFields.Fast);

   // display basic info about each message
   Console.WriteLine("UID | Sequence number | Length");
   foreach (Pop3MessageInfo message in messages)
   {
      Console.WriteLine
      (
         "{0} | {1} | {2} ",
         message.UniqueId,
         message.SequenceNumber,
         message.Length
      );
   }   
}
finally
{
   // leave the server alone
   client.Disconnect();      
}

You may download the component at rebex.net .

BTW - the System.Net.SmtpClient implements the SMTP protocol which can be used for sending emails, not for reading them.
 

Answer 4

Hi friends,
Suppose i want to download a file from another website.May i use this POP3 server?How can i do it?Thanks in advance
 

Answer 5

Hi,
POP3 is for downloading mail messages. If you want to download a file from a web server you should use Http client component such as HttpWebRequest included in the .NET Framework.
 

Answer 6

Hi friend,
I have to login that website to how can i do it?can u give  me a sample.Thanks in advance

 

Answer 7

You can refer following article to read email through pop3

http://www.codeproject.com/KB/IP/NetPopMimeClient.aspx


If you want to download the file and login to a file you can use HttpWebRequest/HttpWebResponse or WebClient. You can set your credentials to login to that site.

 

Answer 8

Hi,

Check out this code  example using the .NET Ultimate Mail component ; some other samples are available at ComponentSoft IMAP's Blog :

// Create a new instance of the ImapClient class.
ImapClient client = newImapClient();
// Connect to the server.
client.Connect( "myserver", 993, SecurityMode.Implicit);
// Login to the server.
client.Authenticate( "user", "password");
StringBuilder sb =
new StringBuilder();
MailboxCollection list = client.ListMailboxes();
for( inti = 0; i < list.Count; i++)
{
   sb.AppendFormat(
"{0} - {1}\r\n", i + 1, list[i].Name);
}
Console.WriteLine(sb.ToString());
// Close the connection.
client.Disconnect();

 

 
 
Search for  Open my gmail Inbox
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter