Esempio n. 1
0
        public void ScheduleMail(MailMessage email, string jobId, DateTime delay, [CallerMemberName] string memberName = "")
        {
            using (var stringWriter = new StringWriter())
            {
                using (var mailMessageXmlWriter = new XmlTextWriter(stringWriter))
                {
                    var mailMessage = new SerializableMailMessage {
                        Email = email
                    };
                    mailMessage.WriteXml(mailMessageXmlWriter);
                    mailMessageXmlWriter.Flush();

                    var data = stringWriter.ToString();
                    jobManager.Schedule(jobId, () => Send(memberName, email.To.ToString(), data), delay);
                }
            }
        }
Esempio n. 2
0
        public void EnqueueMail(MailMessage email, [CallerMemberName] string memberName = "")
        {
            using (var stringWriter = new StringWriter())
            {
                using (var mailMessageXmlWriter = new XmlTextWriter(stringWriter))
                {
                    var mailMessage = new SerializableMailMessage {
                        Email = email
                    };
                    mailMessage.WriteXml(mailMessageXmlWriter);
                    mailMessageXmlWriter.Flush();

                    var data = stringWriter.ToString();
                    BackgroundJob.Enqueue(() => Send(memberName, email.To.ToString(), data));
                }
            }
        }