maintain email servers. SendGrid manages all of the technical details, from scaling the
infrastructure to ISP outreach and reputation monitoring to whitelist services and real time
analytics.
SendGrid mail code:
using SendGridMail;
using SendGridMail.Transport;
public bool
SendEmailThroughSendGrid(string MailTo, string DisplayName, string Subject, string MailFrom, string MailBody)
{
try
{
string sgUsername = "***********";
string sgPassword = "***************";
SendGrid myMessage =
SendGrid.GetInstance();
myMessage.AddTo(MailTo);
myMessage.From = new
MailAddress(MailFrom, DisplayName);
myMessage.Subject =
Subject;
myMessage.Text = "";
myMessage.Html =
MailBody;
var
credentials = new NetworkCredential(sgUsername,
sgPassword);
var
transportWeb = Web.GetInstance(credentials);
transportWeb.Deliver(myMessage);
return true;
}
catch (Exception)
{
return false;
}
finally
{
}
}