找不到命名空间网站
Namespace web not found
我正在按照 Microsoft 的教程学习如何与 SendGrid 集成。他们的代码是 here.
现在我正在使用 .Net framework 4.5.2 并且在线上出现错误:
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
错误显示 "The type or namespace name 'Web' could not be found."
我在网上搜索过,找不到太多相关信息。我得到了他们在页面中提到的所有命名空间。
谁能给我一些线索?
谢谢。
贝哈达
检查您是否已将 SendGrid
包添加到您的项目中。然后,将 using SendGrid;
添加到您的 class。
如果您已经这样做,您可以单击 Web
并按 Alt + Shift + F10
查看可用的选项。
好的,如果其他人在尝试将他们的 MVC 5 项目配置为所有发送确认电子邮件时遇到困难,这里是信息:
- 我一直在关注 this page
- 我遇到的问题是我看不到命名空间 Web
- 因此,在 Azure 上创建 SendGrid 帐户后,在 Sendgrid.com 上使用 username/password 并获取 API 密钥
然后使用 API 键,使用以下代码发送您的电子邮件:
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("test@example.com", "Example User");
var subject = message.Subject;
var to = new EmailAddress("test@example.com", "Example User");
var plainTextContent = message.Body;
var htmlContent = message.Body;
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
await client.SendEmailAsync(msg);
}
以上代码复制自here.
我正在按照 Microsoft 的教程学习如何与 SendGrid 集成。他们的代码是 here.
现在我正在使用 .Net framework 4.5.2 并且在线上出现错误:
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
错误显示 "The type or namespace name 'Web' could not be found." 我在网上搜索过,找不到太多相关信息。我得到了他们在页面中提到的所有命名空间。
谁能给我一些线索?
谢谢。 贝哈达
检查您是否已将 SendGrid
包添加到您的项目中。然后,将 using SendGrid;
添加到您的 class。
如果您已经这样做,您可以单击 Web
并按 Alt + Shift + F10
查看可用的选项。
好的,如果其他人在尝试将他们的 MVC 5 项目配置为所有发送确认电子邮件时遇到困难,这里是信息:
- 我一直在关注 this page
- 我遇到的问题是我看不到命名空间 Web
- 因此,在 Azure 上创建 SendGrid 帐户后,在 Sendgrid.com 上使用 username/password 并获取 API 密钥
然后使用 API 键,使用以下代码发送您的电子邮件:
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("test@example.com", "Example User"); var subject = message.Subject; var to = new EmailAddress("test@example.com", "Example User"); var plainTextContent = message.Body; var htmlContent = message.Body; var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); await client.SendEmailAsync(msg); }
以上代码复制自here.