HI ,

I want to import emails from my Gmail account to my application, can anybody please help me out with code , links or procedure for to implement this .

Thanks in Advance
:) :) :) :)

Recommended Answers

All 4 Replies

Hi,
check here for all the info needed (scrool down to "Retrieving contacts" to get sode snippets).

Thanks a lotssss for your help.
actully i am looking for code for to get email i.e the message body .

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.

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.

And here are some other solutions too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.