Home / Companies / Twilio / Blog / Post Details
Content Deep Dive

How to send Email in C# .NET using SMTP and SendGrid

Blog post from Twilio

Post Details
Company
Date Published
Author
Niels Swimberghe
Word Count
2,579
Language
English
Hacker News Points
-
Summary

To send emails using SMTP with SendGrid, you need to first configure your SendGrid account by setting up Sender Authentication and creating a SendGrid API key. You can then use either the built-in .NET APIs or the MailKit library to connect to SendGrid's SMTP server, authenticate using the API key, create an email message, and send it. The application should be run with the SENDGRID_API_KEY environment variable set to the actual API key value. Alternatively, you can configure SmtpClient to pull these values from external configuration in .NET applications. To add more SendGrid functionality to your emails, you can append additional headers using SendGrid's C# .NET library. Sending emails using SMTP with SendGrid is mostly the same as sending emails with other SMTP servers, but using the SendGrid C# .NET library provides access to more features and APIs.