Home > Enterprise >  GMail API / OAUTH2 - How To Send Emails With Traditional C# SMTP Method Being Deprecated?
GMail API / OAUTH2 - How To Send Emails With Traditional C# SMTP Method Being Deprecated?

Time:03-09

As per notice from Google's enter image description here

// C# code
using (SmtpClient smtpClient = new SmtpClient(SmtpDomain, SmtpPortNumber))
{
    smtpClient.DeliveryMethod = SmtpDeliveryMethod;
    smtpClient.UseDefaultCredentials = UseDefaultCredentials;
    smtpClient.EnableSsl = true;
    smtpClient.Credentials = new NetworkCredential(SmtpUsername, appsPasswrod);

    MailMessage mailMessage = new MailMessage { /* ... */ };
    
    smtpClient.Send(mailMessage);
}
  • Related