How can I send e-mail through Gmail with C

From AfterLogic Wiki

Jump to: navigation, search

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

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();
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()