Search This Blog

Tuesday, December 19, 2017

What is sendgrid ??

SendGrid is a cloud-based SMTP provider that allows you to send email without having to 

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
        {

        }
    }




1 comment :

Unknown said...

Best selenium online training institute `