My asp.net application send Invitation emails and conformation emails , i want to create one component that handle sending mails and be flexible to use HTML templates for the emails and this emails will contain links for invitation or confirmation can someone tell me how i can design this compoenet
I assume that you know how to send emails using asp.net,
Now Your question was how to send using templates
- You could first design a Layout for your E-mail or newsletter which ever the case may be
2.Implement a Class which basically holds the following information
class email {
string header; // header= @" string body;// the body may contain the actual message string Footer;
}
you could expose some parts of the mark up as properties for convenience
class email {
string header; // header= @" string body;// the body may contain the actual message string Footer; ..........properties here
public string getmail() { return header+body+string;
}
}
<% @Page Language="C#" %> <% @Import Namespace="System.Web.Mail" %> <% MailMessage msgMail = new MailMessage();
msgMail.To = "[email protected]"; msgMail.Cc = "[email protected]";i msgMail.From = "[email protected]"; msgMail.Subject = "Hello WOrld";
msgMail.BodyFormat = MailFormat.Html;
Email mail=new Email;
msgMail.Body = mail.getemail()
SmtpMail.Send(msgMail);