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錯誤:的Windows Phone 8 sendGridMessage編譯錯誤
- 錯誤CS0570: 「SendGrid.SendGridMessage.From」不被支持的語言
- 錯誤CS1502:爲「SendGrid.Web.Web(串)」的最佳重載的方法匹配具有一些無效參數
- 錯誤CS1503:參數1:不能轉換從'System.Net.NetworkCredential'到'string'
我已經使用這個網站「https://azure.microsoft.com/tr-tr/documentation/articles/sendgrid-dotnet-how-to-send-email/」作爲參考。
錯誤源於因爲應用程序是Windows Phone應用程序還是什麼?
是否有任何其他方式通過在代碼中聲明「from」來發送電子郵件?
謝謝你的指導答案。其實我試圖通過Azure發送電子郵件,但它只在我更改了數據(插入,更新...)上的數據時才起作用。但我會搜索後端服務器謝謝。然後我有另一個問題:用戶可以從App.xaml.cs中的此代碼獲取我的Azure帳戶: public static MobileServiceClient MobileService = new MobileServiceClient( 「」,「」); 將應用程序中的重要數據存儲在應用程序中是否安全,而無需使用憑據和Web類? – Pumpkin