我安裝了SendGrid軟件包,但是我得到了下面的使用direktive缺少的錯誤。C#SendGrid using-direktive missing
類型或命名空間名稱「SendGridMessage」無法找到(我們的項目上的.NET Framework 4.5.2運行)(是否缺少using指令或程序集引用?)
名稱「ConfigurationManager中」在目前情況下不存在
「ConfigurationManager中」這個名字並不在當前的背景下
類型或命名空間名稱「網絡」存在找不到(是否缺少using指令或程序集引用?)
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using AWE.Models;
using SendGrid;
using System.Net;
using System.Net.Http;
using System.Net.Mail;
using SendGrid.Helpers.Mail;
using System.Web.Mail;
using System.Web.Script.Serialization;
public class EmailService : IIdentityMessageService
{
public Task SendAsync(IdentityMessage message)
{
return configSendGridasync(message);
}
private Task configSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new System.Net.Mail.MailAddress(
"[email protected]", "Joe S.");
myMessage.Subject = message.Subject;
myMessage.Text = message.Body;
myMessage.Html = message.Body;
var credentials = new NetworkCredential(
ConfigurationManager.AppSettings["awe7"],
ConfigurationManager.AppSettings["mailPassword"]
);
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
if (transportWeb != null)
{
return transportWeb.DeliverAsync(myMessage);
}
else
{
return Task.FromResult(0);
}
}
}
我無法查看圖像。你能否將相關信息複製到問題中? –
不要在圖片中顯示您的代碼。把它作爲文本在你的問題。並顯示確切的錯誤信息,你正在得到。波浪線不會告訴我們很多。 – mason
如果你點擊紅色的波形並按下CTRL +,會發生什麼情況。 ? – Neil