How to send a dynamic email from Sendgrid in .net core

Last Reply 11 days ago By dharmendr

Posted 14 days ago

How to send a dynamic email from Sendgrid in .net core 

I have use this code for send Email but email send with this message (SendGrid.Response)

var sendGridClient = new SendGridClient("SG.W_i24ty6eg.Rg7XZJj1bRSfAMah1nPeaZZj1EdF2xs1Qf_9FTTjTSM");
var sendGridMessage = new SendGridMessage();
sendGridMessage.SetFrom("esso.dotnet@gmail.com", "Example");
sendGridMessage.AddTo("suno777@gmail.com");
//The Template Id will be something like this - d-9416e4bc396e4e7fbb658900102abaa2
sendGridMessage.SetTemplateId("d-b15715e51b4d51b25d121e0de8b949");
//Here is the Place holder values you need to replace.
sendGridMessage.SetTemplateData(new
{
    name = "Anuraj",
    url = "https://dotnetthoughts.net"
});
 
var response = await sendGridClient.SendEmailAsync(sendGridMessage);
if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
{
    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email ", response.ToString());
}

 

You are viewing reply posted by: dharmendr 11 days ago.