Home >Backend Development >C++ >How to Send Personalized Emails from Gmail using .NET?
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
<code class="language-csharp">var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) };</code>
<.> 4. Two steps to verify
If you enable two -step verification in the Google account, you must: MailMessage
<code class="language-csharp">using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); }</code>The application password is generated by accessing the Google account security page and under the instructions under the "application password".
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!