Reputation:
I am following through the tutorial by Microsoft to integrate with SendGrid. Their code is here.
Now I am using .Net framework 4.5.2 and I am getting an error on the line:
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
The error says "The type or namespace name 'Web' could not be found." I have searched online and couldn't find much about it. I have got all the namespaces that they have mentioned in the page.
Anyone can give me some clues please?
Thanks. Behdad.
Upvotes: 2
Views: 1293
Reputation:
Ok for anyone else getting stuck trying to configure their MVC 5 project to all sending confirmation emails here is the information:
Then using that API key, use the following code to send your emails:
private async Task configSendGridasync(IdentityMessage message)
{
var apiKey = ConfigurationManager.AppSettings["NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY"];
var client = new SendGridClient(apiKey);
var from = new EmailAddress("[email protected]", "Example User");
var subject = message.Subject;
var to = new EmailAddress("[email protected]", "Example User");
var plainTextContent = message.Body;
var htmlContent = message.Body;
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
await client.SendEmailAsync(msg);
}
The above code was copied from here.
Upvotes: 2
Reputation: 5610
Check if you have added the SendGrid
package to your project. Then, add using SendGrid;
to your class.
If you have already, you may click on Web
and press Alt + Shift + F10
to see options available.
Upvotes: 0