/// <summary> /// Build the mail message. /// </summary> public void Build(IAction <MailMessage> onBuilt, Elements elements = null) { MailMessage mail = new MailMessage(); mail.From = new MailAddress(From); if (To != null) { foreach (var to in To) { mail.To.Add(to); } } if (_bcc != null) { foreach (var bcc in _bcc) { mail.Bcc.Add(bcc); } } if (_cc != null) { foreach (var cc in _cc) { mail.CC.Add(cc); } } mail.BodyEncoding = System.Text.Encoding.UTF8; mail.Subject = Subject; if (BodyString != null) { mail.Body = BodyString; } else if (BodyElement != null) { mail.IsBodyHtml = true; BodyElement.Build(elements, Act.New(OnBuilt, (Element)null, mail, onBuilt)); return; } else { throw new InvalidOperationException("Neither BodyString nor BodyElement was set."); } onBuilt.ArgA = mail; ManagerUpdate.Control.AddSingle(onBuilt.Run); }
public ConfigBuilder WithElement(ElementBuilder element) { return(WithElement(element.Build())); }
public ConfigBuilder WithElement(ElementBuilder element) { elements.Add(element.Build()); return(this); }