【问题标题】:Windows Phone 8 sendGridMessage Compile errorWindows Phone 8 sendGridMessage 编译错误
【发布时间】: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 个错误:

  1. 错误 CS0570:该语言不支持“SendGrid.SendGridMessage.From”
  2. 错误 CS1502:“SendGrid.Web.Web(string)”的最佳重载方法匹配有一些无效参数
  3. 错误 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


    【解决方案1】:

    这并不是对您问题的真正答案,但重要的是我将其作为答案而不是评论。

    这不是从移动设备发送电子邮件的安全方式,因为您将包含凭据的代码提供给安装用户。他们需要做的就是检查来自您的应用的流量,并且您的 SendGrid API 密钥或帐户已被盗用。

    您需要向某个安全的后端服务器(或提供商,例如 Parse 或 Azure)发出请求,然后从该服务器而不是客户端应用程序发送电子邮件。

    如果您想调试代码,请查看 Github 上的自述文件和示例。微软的文档很快就过时了。 https://github.com/sendgrid/sendgrid-csharp

    【讨论】:

    • 感谢您的指导性回答。实际上,我曾尝试通过 Azure 发送电子邮件,但它仅在我更改表上的数据(插入、更新...)时才有效。但我会搜索后端服务器,谢谢。然后我有另一个问题:用户可以从 App.xaml.cs 中的此代码获取我的 Azure 帐户: public static MobileServiceClient MobileService = new MobileServiceClient( "","" );在不使用凭据、Web 类的情况下在应用中存储重要数据是否安全?
    猜你喜欢
    • 1970-01-01
    • 2012-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-12
    相关资源
    最近更新 更多