Directly using your Gmail account from the .NET application to send emails to provide more control and custom options. The following is the method of achieving this goal:
<.> 1. Choose the correct .NET naming space
Use Naming space instead of the abandoned to process email communication.
<.> 2. Configure the SMTP client System.Net.Mail
System.Web.Mail
Object:
<.> 3. Create and send emails SmtpClient
var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) };
<.> 4. Two steps to verify
If you enable two -step verification in the Google account, you must: MailMessage
using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); }
The generated applied password is used as in the
attribute.
SmtpClient
The above is the detailed content of How to Send Personalized Emails from Gmail using .NET?. For more information, please follow other related articles on the PHP Chinese website!