Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I need to know the basis C# logic to fetch emails from imap.gmail.com
Please do not give me any library, i need to build my own code.

I think this should be implemented using TCP listener. but i donot know the whole story to implement this.

Please guide.
Posted

1 solution

Here's a sample using AE.Net.Mail[^]:

C#
// Connect to the IMAP server. The 'true' parameter specifies to use SSL
// which is important (for Gmail at least)
ImapClient ic = new ImapClient("imap.gmail.com", "name@gmail.com", "pass",
                ImapClient.AuthMethods.Login, 993, true);
// Select a mailbox. Case-insensitive
ic.SelectMailbox("INBOX");
Console.WriteLine(ic.GetMessageCount());
// Get the first *11* messages. 0 is the first message;
// and it also includes the 10th message, which is really the eleventh ;)
// MailMessage represents, well, a message in your mailbox
MailMessage[] mm = ic.GetMessages(0, 10);
foreach (MailMessage m in mm)
{
    Console.WriteLine(m.Subject);
}
// Probably wiser to use a using statement
ic.Dispose();

Cheers,
Edo
 
Share this answer
 
v3
Comments
CHITRAKSH 2010 3-Mar-13 2:00am    
Dear Sir,
What is ImapClient ? is this a library?
I need the code behind ImapClient library
Joezer BH 3-Mar-13 2:06am    
You right!
:)
I forgot to add a link. The solution above is updated.

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