Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
Hi I am looking for a code to retrieve mails and attachments from only inbox,i have done a lot of search on google, at last i found some code here , thanks to the author,but it retrieves all the mails from all the folders(Inbox,sent,trash..), can any one help here

the code follows here, can any one filter it.


C#
public List<Email> FetchEmailList(int start, int count)
        {
            List<Email> emails = new List<Email>(count);
            for (int i = start; i < (start + count); i++)
            {
                Email email = FetchEmail(i);
                if (email != null)
                    emails.Add(email);
            }
            return emails;
        }


SQL
public Email FetchEmail(int emailId)
        {
            if (IsResponseOk(SendCommand("TOP " + emailId + " 0")))
                return new Email(ReadLines());
            else
                return null;
        }




Thanks in advance.
Posted
Updated 21-Sep-13 3:46am
v8
Comments
[no name] 21-Sep-13 9:10am    
"I want a code", okay so learn C# and write some code.
Joan M 21-Sep-13 9:10am    
We've not seen the code, we don't know which are your problems, we won't use google for you to search for code... Improve your question and try it again.

Some times it's a good idea trying to get some background about what you're willing to do. For downloading e-mails from the server you use what is called e-mail protocol. Two of the most commonly used ones are POP3 and IMAP. With this in mind you can go and search for something like "pop3 client c#"[^]

The OpenPop.NET[^] library implements the protocol and also the MIME parser.

You will find something about IMAP (client) here: Simple IMAP CLIENT[^] and here: IMAP and POP3 Clients in C#[^].

Looking at those projects you'll get part of the background you need for it.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Sep-13 22:13pm    
My 5.
—SA
V.Lorz 22-Sep-13 3:21am    
Thank you, Sergey.
V.Lorz
You should post your question in the forum at the end of the article so the author can see it.
 
Share this answer
 
XML
hi
Thanks all  for your suggestion
i am able to find my solution here "http://www.limilabs.com/blog/download-emails-from-gmail#comment-572692"
 
Share this answer
 
v3

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