Send email in C# code


I am looking to send out an email when an invoice is generated in my code ( website) - is there an example of the code to send out an email?


You can start with the System.Net.Mime namespace:

Then you have the System.Net.Mail namespace:

You will craft a MailMessage object:
:arrow_up: This page has example code you are looking for :slightly_smiling_face:

And send it with the SmtpClient class:


I send transactional email (reminders, confirmations, etc) from my site. I have used SendGrid and Mailgun to handle the email. Both are pretty simple to incorporate into your site.