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 = "Congratulations! you have got the email";
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.

Gowtham CpPosted Aug 16, 2024, 4:07 PM
To get real-time email delivery updates on your front-end, you can use SignalR. First, connect to your SignalR hub by specifying its URL. Next, listen for status updates using connection.on("ReceiveStatusUpdate", ...), which lets you update your UI with the latest email status as soon as it’s available. Start the connection with connection.start() and handle any errors that come up.
Kranthi Vardhan KolluruPosted Aug 16, 2024, 10:18 AM
Thank you Goutham,
How should i call this response in front end immedietly after sending the email to the customer. I mean i want the status of email delivery immedetly after sending the mail. Could you please give some code in C# to get this response
Gowtham CpPosted Aug 15, 2024, 9:04 AM
Hi Kranthi,
Here’s a streamlined example of a web service to handle SendGrid webhook notifications:
1. Project Setup:
2. Webhook Controller:
3. Configure SendGrid Webhook:
- Set the webhook URL in SendGrid (e.g., `https://yourdomain.com/api/webhook`).
- Choose the events to track (e.g., delivered, bounced).
Kranthi Vardhan KolluruPosted Aug 14, 2024, 10:20 AM
Hi Goutham,
Thanks for the response.
I created all the webhook setup in sendgrid but i am failing to create the service i have no idea on this how to access response after email sent
Could you please provide that web service code to handle these notifications, i tried a lot i was not found any suitable code.
Gowtham CpPosted Aug 13, 2024, 1:36 PM
You’re not receiving email delivery statuses because SendGrid’s
SendEmailAsynconly confirms that the email was accepted, not its final status. To track delivery, bounces, and other events, set up a webhook in SendGrid that sends event notifications to your C# endpoint. Create a simple web service (e.g., using ASP.NET Core) to handle these notifications, process the data, and log or act on the email statuses.