public void Send(string messageType, string to, string mailMessageString) { using (var mailMessageXmlReader = new XmlTextReader(new StringReader(mailMessageString))) { mailMessageXmlReader.Read(); var mailMessage = new SerializableMailMessage(); mailMessage.ReadXml(mailMessageXmlReader); mailerEngine.Send(mailMessage.Email); } }
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); } } }
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)); } } }