I am using SendGrid C# code to send the emails, i was successfully sent the emails but in response i am not getting delivery status. If i send mail to wrong email address also, it is giving success response i am not getting bounce status response. Then i did some R&D how to get the delivery status, then i came to know about Webhook. I am new to Webhook i created a webhook URL in keen webiste and pasted in SendGrid webook events.
my normal Sendgrid email C# code
Environment.SetEnvironmentVariable("SENDGRID_API_KEY", "xxxxx");
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
var client = new SendGridClient(apiKey);
var from = new EmailAddress("[email protected]", "CAP");
var subject = "Testing email from Sendgrid";
var to = new EmailAddress("[email protected]", "Good User");
var plainTextContent = "Hello, ";
var htmlContent = "<strong>Congratulations! you have got the email</strong>";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
msg.SetBypassBounceManagement(true);
msg.TrackingSettings = new TrackingSettings()
{
ClickTracking = new ClickTracking()
{
Enable = true,
EnableText = false
},
OpenTracking = new OpenTracking()
{
Enable = true,
SubstitutionTag = "%open-track%"
},
SubscriptionTracking = new SubscriptionTracking()
{
Enable = false
}
};
var response = await client.SendEmailAsync(msg).ConfigureAwait(false);
But i don't know how to get the delivery status in response after sending email. Any one please help on this.