Sending email from Azure with C# using SendGrid’s public service
Posted: (EET/GMT+2)
Microsoft's Azure cloud service does not have a built-in email handling service, but that doesn't mean you couldn't send email from your Azure applications. Shortly put, you can use your own SMTP server (say, the one from your ISP), or use SMTP and/or web-based interfaces for popular third-party mail sending solutions.
One good alternative especially for Azure users is SendGrid, which offers 25,000 emails per month on their Free level for Azure customers. They also provide a nice C# API, which you can easily install into your, say, ASP.NET web application as a NuGet package.
They also provide coding examples, so you can get up to speed quickly. Here's a quick example:
using SendGrid;
SendGridMessage message = new SendGridMessage();
message.From = new MailAddress("me@somewhere.com");
List recipients = new List()
{
"Jeff Smith ",
"Anna Lidman ",
"Peter Saddow "
};
message.AddTo(recipients);
message.Subject = "Hello using SendGrid";
message.Html = "<h1>Hello, World!</h1>";
string username = "my-sendgrid-username";
string pwd = "secret$1234";
NetworkCredential credentials = new NetworkCredential(username, pwd);
Web transportWeb = new Web(credentials);
transportWeb.Deliver(message);
Hope this helps!