Mail |
public abstract void Disconnect( bool quit, CancellationToken cancellationToken = default )
Exception | Condition |
---|---|
ObjectDisposedException | The MailService has been disposed. |
public static void SendMessage (MimeMessage message) { using (var client = new SmtpClient ()) { client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect); client.Authenticate ("username", "password"); client.Send (message); client.Disconnect (true); } }