设备脱机时Xamarin.android会对电子邮件进行排队,并在设备联机时重试发送

时间:2018-06-11 08:53:41

标签: xamarin.android smtpclient

我使用SMTP客户端发送带有动态HTML内容的电子邮件,但这只适用于设备在线时。 有没有什么方法可以排队等待设备重新上线时尝试重新发送?

以下是我目前的代码:

            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

            mail.From = new MailAddress(“xyz@gmail.com”);
            mail.To.Add(customerEmailId);
            mail.Subject = "Receipt for Order #";

            mail.Body = createHtml(); //get dynamic HTML content from here
            mail.IsBodyHtml = true;

            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential(“abc@gmail.com”, “abcdef”);

            SmtpServer.EnableSsl = true;
            ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                return true;
            };
            SmtpServer.Send(mail);

0 个答案:

没有答案