public MailMessage BuildTemplatedMessage( MailPriority priority, string from, string sender, string replyTo, List <string> toAddresses, List <string> ccAddresses, List <string> bccAddresses, string templateName, Dictionary <string, object> dataObjects) { NetMailTemplate template = this.Templates[templateName]; if (template == null) { throw new NetMailException("A template named '" + templateName + "' can not be found. Email message failed to be constructed"); } string subject = template.GenerateSubject(dataObjects); string body = template.GenerateBody(dataObjects); bool htmlFormat = template.BodyStyle == NetMailTemplateTextStyle.HTML; return(this.BuildMessage(subject, body, htmlFormat, priority, from, sender, replyTo, toAddresses, ccAddresses, bccAddresses)); }
/// <summary> /// Adds a template to the templates list /// </summary> /// <param name="name"></param> /// <param name="subject"></param> /// <param name="bodyFile"></param> /// <param name="textStyle"></param> /// <param name="parserType"></param> public void AddTemplate(string name, string subject, string bodyFile, NetMailTemplateTextStyle textStyle, NetMailTemplateParserType parserType) { if (this.Templates == null) { this.Templates = new Dictionary <string, NetMailTemplate>(); } NetMailTemplate template = new NetMailTemplate(); template.MessageBodyFile = bodyFile; template.MessageSubject = subject; template.BodyStyle = textStyle; template.BodyParserType = parserType; this.templates.Add(name, template); }