Download emails from GMail via POP3

Accessing Gmail with POP3 is a bit different that accessing other POP3 servers. Still is quite easy with Mail.dll IMAP client. Remember that POP3 protocol unlike IMAP does not store the unseen information on the server.
Mail.dll has of course IMAP support
First we need to make sure that POP3 access is enabled for your GMail account.
- Go to GMail settings:
- Then select ‘Forwarding and POP/IMAP’ tab:
- And check one of the ‘Enable …’ options in ‘IMAP Access’ section:
-
GMail behaves differently than other POP3 servers and its POP3 configuration may be sometimes confusing.
Luckily you can configure what you expect from it. Here’s the value list of drop down list called “When messages are accessed with POP” and the Gmail’s behavior:- “delete Gmail’s copy”: Message is deleted by issuing GetMessage command.
- “keep Gmail’s copy in the Inbox”: Message stays in the Inbox, Web interface says it’s unread, however message is not received for the second time using POP3 client.
- “archive Gmail’s copy”: Message is deleted by issuing GetMessage command, however it is possible to find it using web interface.
- Now you are able to connect to your GMail account with Mail.dll POP3 client.
If you want to have a greater control over your mail you should use
Mail.dll .NET IMAP client. You can easily move messages between folders (IMAP calls them mailboxes) and flag them.
Remember that GMail only allows secure SSL connections so we need to use ConnectSSL method.
// C# code:
using(Pop3 pop3 = new Pop3())
{
pop3.ConnectSSL("pop.gmail.com");
pop3.Login("your_email@gmail.com", "password");
foreach (string uid in pop3.GetAll())
{
string eml = pop3.GetMessageByUID(uid);
IMail mail= new MailBuilder()
.CreateFromEml(eml);
Console.WriteLine(mail.Subject);
Console.WriteLine(mail.TextDataString);
}
pop3.Close(false);
}
' VB.NET code:
Using pop3 As New Pop3()
pop3.ConnectSSL("pop.gmail.com")
pop3.Login("your_email@gmail.com", "password")
For Each uid As String In pop3.GetAll()
Dim email As IMail = New MailBuilder() _
.CreateFromEml(pop3.GetMessageByUID(uid))
Console.WriteLine(email.Subject)
Console.WriteLine(mail.TextDataString)
Next
pop3.Close(False)
End Using
If you like the idea of simple GMail access just give it a try for yourself and download it at: Mail.dll .NET email component
