私はC#ASP.NETアプリケーションでSendGridをセットアップするチュートリアルに従ってきました。 示唆したように、私は私のIdentityConfig.csに次のコードを持っている:C#SendGrid - SendAsyncメソッドエラー
using SendGrid;
using System.Net;
using System.Configuration;
using System.Diagnostics;
using Microsoft.AspNet.Identity;
using System.Threading.Tasks;
using SendGrid.Helpers.Mail;
public async Task SendAsync(IdentityMessage message)
{
await configSendGridasync(message);
}
// Use NuGet to install SendGrid (Basic C# client lib)
private async Task configSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new EmailAddress(
"[email protected]", "John Lowry");
myMessage.Subject = message.Subject;
myMessage.PlainTextContent = message.Body;
myMessage.HtmlContent = message.Body;
var credentials = new NetworkCredential(
ConfigurationManager.AppSettings["mailAccount"],
ConfigurationManager.AppSettings["mailPassword"]
);
// Create a Web transport for sending email.
**var transportWeb = new Web(credentials);**
// Send the email.
if (transportWeb != null)
{
await transportWeb.DeliverAsync(myMessage);
}
else
{
Trace.TraceError("Failed to create Web transport.");
await Task.FromResult(0);
}
}
ラインvar transportWeb = new Web(credentials);
は、エラーの原因となっている。
The type or namespace 'Web' could not be found
私がオンラインになり、SendGrid.Web(credentials)
が有効であるが、それはありません私のために。
何か不足していますか?
おかげで、 ジョン
マニュアルを参照してくださいする必要があり、あなたが使用していることをsendgrid V3を使用している場合は?バージョンの問題の不一致かもしれません。 – Sujith
.Net Framework 4.5.2とSendGrid.9.5.0 – Johnathan
'new web'を' new SendGrid.Web'に置き換えたらどうなりますか? – mjwills