【发布时间】:2015-07-21 21:48:29
【问题描述】:
private async void sendMail(string from,string to, string subject,string text)
{
// Create network credentials to access your SendGrid account
string username = "xx";
string pswd = "xx";
MailMessage msg = new MailMessage();
NetworkCredential credentials = new NetworkCredential(username, pswd);
// Create the email object first, then add the properties.
// Create the email object first, then add the properties.
SendGridMessage myMessage = new SendGridMessage();
myMessage.AddTo("xx");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World!";
myMessage.From = new MailAddress(from);
// Create an Web transport for sending email.
var transportWeb = new SendGrid.Web(credentials );
// Send the email.
await transportWeb.DeliverAsync(myMessage);
}
我的应用程序是 Windows Phone 8.1,我尝试通过 sendGrid 发送邮件我创建了一个帐户并将库包含在代码中,但它给出了 3 个错误:
- 错误 CS0570:该语言不支持“SendGrid.SendGridMessage.From”
- 错误 CS1502:“SendGrid.Web.Web(string)”的最佳重载方法匹配有一些无效参数
- 错误 CS1503:参数 1:无法从“System.Net.NetworkCredential”转换为“字符串”
我已使用此站点“https://azure.microsoft.com/tr-tr/documentation/articles/sendgrid-dotnet-how-to-send-email/”作为参考。
错误是因为应用是 Windows Phone 应用还是什么?
还有其他方法可以通过在代码中声明“发件人”来发送电子邮件吗?
【问题讨论】:
标签: c# email azure windows-phone-8 sendgrid