Gmail supports access via IMAP, POP3 and SMTP protocols. Below you can find the configuration settings for all protocols.
All Gmail servers (IMAP, POP3 and SMTP) use implicit SSL – use ConnectSSL method.
IMAP
Server: imap.gmail.com
SSL: true, implicit
Port: 993 (default)
User: pat@gmail.com or pat@your-domain.com
POP3
Server: pop.gmail.com
SSL: true, implicit
Port: 995 (default)
User: pat@gmail.com or pat@your-domain.com
SMTP
Server: smtp.gmail.com
SSL: true, implicit
Port: 465 (default)
User: pat@gmail.com or pat@your-domain.com
Following are the code samples for Mail.dll .NET IMAP, POP3 and SMTP component.
Remember that you must enable IMAP in Gmail or enable POP3 in Gmail first.
// C# using (Imap client = new Imap()) { client.ConnectSSL("imap.gmail.com"); client.UseBestLogin("pat@gmail.com", "password"); ... } using (Pop3 client = new Pop3()) { client.ConnectSSL("pop.gmail.com"); client.UseBestLogin("pat@gmail.com", "password"); ... } using (Smtp client = new Smtp ()) { client.ConnectSSL("smtp.gmail.com"); client.UseBestLogin("pat@gmail.com", "password"); ... }
' VB.NET Using client As New Imap() client.ConnectSSL("imap.gmail.com") client.UseBestLogin("pat@gmail.com", "password") ... End Using Using client As New Pop3() client.ConnectSSL("pop.gmail.com") client.UseBestLogin("pat@gmail.com", "password") ... End Using Using client As New Smtp() client.ConnectSSL("smtp.gmail.com") client.UseBestLogin("pat@gmail.com", "password") ... End Using
You can find more details about using implicit and explicit SSL or TLS with email protocols: