我使用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);