MailBee. NET Objects Tutorials

How can I send e-mail through Gmail with C# or VB.NET

Gmail accepts only secure SSL connections, and thus you should use MailBee.NET SMTP component in SSL mode.

C#

using MailBee;
using MailBee.SmtpMail;
using MailBee.Security;

...
Smtp mailer = new Smtp();
SmtpServer server = new SmtpServer("smtp.gmail.com", "gmail-login", "gmail-password");
server.SslMode = SslStartupMode.UseStartTls;
mailer.SmtpServers.Add(server);
mailer.From.Email = "user@gmail.com";
mailer.To.Add("kathy@company.com");
mailer.Subject = "Report";
mailer.BodyPlainText = "The report contents";
mailer.Send();

VB.NET

Imports MailBee
Imports MailBee.SmtpMail
Imports MailBee.Security

...
Dim mailer As New Smtp
Dim server As SmtpServer = New SmtpServer(smtp.gmail.com", "gmail-login", "gmail-password")
server.SslMode = SslStartupMode.UseStartTls
mailer.SmtpServers.Add(server)
mailer.From.Email = "user@gmail.com"
mailer.To.Add("kathy@company.com")
mailer.Subject = "Report"
mailer.BodyPlainText = "The report contents"
mailer.Send()