public void Send(MailCmd cmd) { SmtpClient client = getSmtpClient(this._settings); if (cmd.Props != null && !cmd.Props.ContainsKey("body")) { cmd.Props.Add("body", cmd.Body); } string htmlBody = getBody(cmd.Props, cmd.Body, cmd.TemplateName, this._settings); var mailMessage = new MailMessage { Subject = cmd.Subject, Body = htmlBody, IsBodyHtml = true, From = string.IsNullOrEmpty(cmd.From) ? null : new MailAddress(cmd.From) }; // add inline attachments addInline(mailMessage, cmd.InlineAttachments, this._settings); // add attachments addAttachments(mailMessage, cmd.Attachments, this._settings); // add receivers addReceivers(mailMessage.To, cmd.To); addReceivers(mailMessage.CC, cmd.CC); addReceivers(mailMessage.Bcc, cmd.Bcc); client.Send(mailMessage); }
public MailCmd Deserialize(string json) { MailCmd cmd = JsonConvert.DeserializeObject <MailCmd>(json); return(cmd); }