Question

How To Read The Gmail Inbox using SMTP

Asked by: MeetuChoudhary

I am Devloping an application in which I need to read the Mails form gmail Inbox of the client. I want To achieve the foolwing Points.

I don't want to use any Third Party Dll like (ASPosse or chilkat).
I want to use SMTP Preafably. or IMAP will do I don't want to use POP3

I am aware about reading unread mails from gmail Feeds Which I don't Want to use Due to These Problems:
   Only unread mails can be read and that to max upto 20 mails.
   the mail body is not included into the feed only summary is included.

In pop3 The problem is that it always stars to read from the First Mail Which I don't Want. I want to strart form the mail where I have Left.

I would Like use C# with ASP.NET to develope my code

I want to devlope code. not to use 3rd party dll

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-24 at 02:01:37ID24675910
Tags

read mail

,

read gmail inbox

,

smtp

Topics

SendMail Email Server

,

Web Services

,

Components

Participating Experts
1
Points
0
Comments
35

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Pros Cons of  SMTP, POP3, IMAP...
    I have Exchange 2000 Enterprise. All of my clients at the host site are "Full Exchange" users (SMTP) However, when we first setup clients at remote sites, they complained that it made their entire office slow. The sites have 128 or 256K VPN connections and run 2-5 ...
  2. smtp
    im using the fedora core 2, now i want one of my server become smtp. (receive and send mail). i knew that i have to activate the pop3 and imap component. Beside this imap and pop3, have any component need to activate? May i know how to activate the pop3 service and imap? any...
  3. SMTP Feed
    We are looking to setup SBS2003. Currently we run a POP3 Server for our email. Currently our ISP holds these for us and we dowload on a timed basis. Because of POP3 not all emails can be accurately redirected, (mailing lists). As a result we are intending to switch over to...
  4. POP, IMAP, SMTP Push
    Hello experts! I have just started working for a small IT outfit who offer IT solutions to relativity small companies around their perimeter. They usually install an exchange server with a POP account (and aliases) set up with an ISP to handle the email. My question is; is ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: gtworekPosted on 2009-08-24 at 02:08:26ID: 25166587

SMTP is for SENDING only. You may read mail using IMAP or POP3.

 

by: MeetuChoudharyPosted on 2009-08-24 at 02:37:15ID: 25166701

Can You please Terll me How To read with IMAP.

 

by: gtworekPosted on 2009-08-24 at 02:38:54ID: 25166710

Look at http://www.example-code.com/csharp/imap.asp
There is a lot of samples.

 

by: gtworekPosted on 2009-08-24 at 02:40:08ID: 25166718

Sorry, wrong link. It is not free component.
Free one (and open source) you can download from http://www.codeproject.com/KB/IP/imaplibrary.aspx

 

by: MeetuChoudharyPosted on 2009-08-24 at 02:43:50ID: 25166740

OK Thanks for the Link I will try that and get back to you soon...

 

by: MeetuChoudharyPosted on 2009-08-24 at 02:51:44ID: 25166773

I downloaded The Attached code and tested its not loging in using imap.gmail.com and username password.

 

by: gtworekPosted on 2009-08-24 at 03:00:44ID: 25166802

I do not why... If you post some code here maybe someone will help... but your information is very limited....

 

by: gtworekPosted on 2009-08-24 at 03:01:26ID: 25166805

One thing more! did you enable IMAP on your gmail account?
could you use such protocol from outlook express or something similar?

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:06:23ID: 25166827

Yes I have Enabled IMAP in my gmail account. And I have no idea about this IMAP and Retriving mail. I just downlaoded the code from the link you provided and run the sample code it failed to login and then  i tried by changing the port no to 993 which is used by outlok to interact with gmail and written in gmail docs. then it waits for so long time and no response came.

 

by: gtworekPosted on 2009-08-24 at 03:10:12ID: 25166846

993 is the IMAP+SSL. you cannot just change the port to use it.

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:14:15ID: 25166862

yes but default oprt for imap is 143 and the code uses 143 port but gmail listens to port 993 so i changed it and tried but no success.

 

by: gtworekPosted on 2009-08-24 at 03:17:24ID: 25166882

993 it is not regular IMAP so you could not use regular IMAP for reading mail... You have to use IMAP over SSL.
Paid component (from the first link) can do this and the free one cannnot.

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:24:35ID: 25166924

but what i want to say is the if that paid component is there that means they have coded for the same functanilty then why can't we. I can't afford paid components. my company don't allow us to buy the components.

 

by: gtworekPosted on 2009-08-24 at 03:28:48ID: 25166944

Great... so you have to begin with IMAP basics... http://tools.ietf.org/html/rfc3501 and http://tools.ietf.org/html/rfc2595

 

by: gtworekPosted on 2009-08-24 at 03:30:58ID: 25166954

I do not know how much do you earn for your coding but I guess it's not worth the price of the paid component... It's just cheaper than many hours of your work.

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:34:53ID: 25166968

I know You are right. But Paid Components are not a solution of a problem in my opinion.

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:36:19ID: 25166976

as far as IMAP basics is concern I know its purpose but I want to use that to read mails... So i need the example of codes for that not the theory

 

by: gtworekPosted on 2009-08-24 at 03:37:07ID: 25166983

Someone coded them so you can be sure it's possible... ;)
With RFC you should have all data you need. But I suppose it's a lot of work if you have to use IMAP+SSL.

 

by: gtworekPosted on 2009-08-24 at 03:38:50ID: 25166992

You have an example on codeproject (second link). But if you have to use SSL it's a much more of work. Encryption requires a lot of dumb coding.

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:41:11ID: 25167008

any clues with that?

 

by: gtworekPosted on 2009-08-24 at 03:44:02ID: 25167024

Look at http://www.openssl.org/ for SSL/TLS handling...

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:49:51ID: 25167058

I don't know what to get from the above link you gave to me. what encryption needs to do here I simply need to read the gmail inbox. I have done it by using pop3 the only problem is it reads from the last mail in the inbox not from the lattest one. and i just want to fecth the unread mails. what can I do.

 

by: gtworekPosted on 2009-08-24 at 03:52:57ID: 25167072

Yes, you have to read it. But IMAP transmission is encrypted on por 993.
Try to configure it with port 143 and then use free component. with 993 you have to decrypt transmission.

 

by: MeetuChoudharyPosted on 2009-08-24 at 03:54:51ID: 25167085

how can i configure it with 143 if the server listens to 993 then it won't be confgured with 143.

 

by: gtworekPosted on 2009-08-24 at 04:00:30ID: 25167120

Could you read data via IMAP _without_ encryption from any client? If not - why do you expect your code can do this?

 

by: MeetuChoudharyPosted on 2009-08-24 at 04:02:17ID: 25167133

So what you suggest what should i do and if should go for any comopnent then which will be better chilkat or asposs or any other.

 

by: gtworekPosted on 2009-08-24 at 04:04:34ID: 25167145

If you cannot disable encryption (probably you cannot) then you have to write code supporting TLS encryption and IMAP protocol. Without such code your app cannot look into mailbox.

 

by: MeetuChoudharyPosted on 2009-08-24 at 04:09:02ID: 25167165

Gmail supports encryption and ssl

even when i used pop3 then also ssl was set to true without this we can't interact with gmail inbox

here is the code I used with pop3 it works then why can't with IMAP

 try
        {
            TcpClient tcpclient = new TcpClient(); // create an instance of TcpClient


            tcpclient.Connect("pop.gmail.com", 995); // HOST NAME POP SERVER and gmail uses port number 995 for POP


            System.Net.Security.SslStream sslstream = new SslStream(tcpclient.GetStream()); // This is Secure Stream // opened the connection between client and POP Server


            sslstream.AuthenticateAsClient("pop.gmail.com"); // authenticate as client


            //bool flag = sslstream.IsAuthenticated; // check flag


            System.IO.StreamWriter sw = new StreamWriter(sslstream); // Asssigned the writer to stream


            System.IO.StreamReader reader = new StreamReader(sslstream); // Assigned reader to stream


            sw.WriteLine("USER "+ txtUserNAme.Text); // refer POP rfc command, there very few around 6-9 command


            sw.Flush(); // sent to server


            sw.WriteLine("PASS "+txtPass.Text);
            sw.Flush();


            sw.WriteLine("RETR 1"); // this will retrive your first email


            sw.Flush();


            sw.WriteLine("Quit "); // close the connection


            sw.Flush();


            string str = string.Empty;
            string strTemp = string.Empty;


            while ((strTemp = reader.ReadLine()) != null)
            {


                if (strTemp == ".") // find the . character in line
                {

                   
                    break;
                }


                if (strTemp.IndexOf("-ERR") != -1)
                {


                    break;
                }


                str += strTemp;


            }


            Response.Write(str);


            Response.Write("<BR>" + "Congratulation.. ....!!! You read your first gmail email ");
 

If it can't then please suggest me which componet will be better to purchase?

 

by: gtworekPosted on 2009-08-24 at 04:14:43ID: 25167195

Look into RFC 3501. You can read inside how to "talk" with IMAP server. You may also look into codeproject component. In your code you have SSL supported. You can do same thing with IMAP.

 

by: MeetuChoudharyPosted on 2009-08-24 at 04:17:45ID: 25167209

can you please describe a bit more I didn't get what you want to say?

 

by: gtworekPosted on 2009-08-24 at 04:25:17ID: 25167244

you have:

 sw.WriteLine("USER "+ txtUserNAme.Text);
 sw.Flush(); // sent to server
 sw.WriteLine("PASS "+txtPass.Text);
 sw.Flush();
 sw.WriteLine("RETR 1"); // this will retrive your first email
 sw.Flush();
 sw.WriteLine("Quit "); // close the connection

for USER, PASS, RETR and QUIT command

Connect to 995 to imap.gmail.com and issue LOGIN, SELECT, LIST and CLOSE as described in RFC3501.

 

by: MeetuChoudharyPosted on 2009-08-24 at 04:34:18ID: 25167288

What does "described in RFC3501." Means?

 

by: MeetuChoudharyPosted on 2009-08-24 at 05:14:56ID: 25167507

Thanks for your time I got the solution from pop server only here is the link:
http://www.codeproject.com/KB/cs/email_client_application.aspx

 

by: MeetuChoudharyPosted on 2009-08-24 at 05:16:42ID: 25167511

but i wold like to get the solution for imap also if some can help?

 

by: MeetuChoudharyPosted on 2009-09-14 at 22:42:22ID: 25332009

I found the answer by myself using pop3 still if there are any experts who can through some light onn the qusetion using IMAP are welcomed

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...