I want to send email using SendGrid using Azure function. I am using c# code to do it. Below is my sample code. When I compile the code, I am getting below error,
#r "System.Configuration"
#r "System.Data"
#r "SendGrid"
using System;
using System.Net;
using System.Configuration;
using SendGrid;
using SendGrid.Helpers.Mail;
public static async Task < HttpResponseMessage > Run(HttpRequestMessage req, TraceWriter log) {
var client = new SendGridClient(sendgridApiKey);
var msg = new SendGridMessage()
{
From = new EmailAddress("sample@gmail.com", "DX Team"),
Subject = "Hello World from the SendGrid CSharp SDK!",
PlainTextContent = "Hello, Email!",
HtmlContent = "<strong>Hello, Email using HTML!</strong>"
};
var recipients = new List<EmailAddress>
{
new EmailAddress("test@gmail.com", "John"),
new EmailAddress("sa@gmail.com", "Sam")
};
msg.AddTo(recipients);
msg.SetFooterSetting(
true,
"Some Footer HTML",
"<strong>Some Footer Text</strong>");
var response = await client.SendEmailAsync(msg);
}
Error:-
The type or namespace name 'SendGridClient' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'SendGridMessage' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'EmailAddress' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'EmailAddress' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'EmailAddress' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'EmailAddress' could not be found (are you missing a using directive or an assembly reference?)
Compilation failed.
My references is here
How do I solve this?