| SmtpClient Constructor |
Initializes a new instance of the
SmtpClient class.
Namespace: MailKit.Net.SmtpAssembly: MailKit (in MailKit.dll) Version: 4.7.1
Syntax Remarks
Before you can send messages with the
SmtpClient, you must first call one of
the
Connect methods.
Depending on whether the SMTP server requires authenticating or not, you may also need to
authenticate using one of the
Authenticate methods.
Example public static void SendMessages (IList<MimeMessage> messages)
{
using (var client = new SmtpClient ()) {
client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
client.Authenticate ("username", "password");
foreach (var message in messages) {
client.Send (message);
}
client.Disconnect (true);
}
}
See Also