views:

45

answers:

1

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

A: 

I assume that you know how to send emails using asp.net,

Now Your question was how to send using templates

  1. 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);

Vivek Bernard
yes this what i need , i will start with your idea, I will add property URL that may be needed if this invitation email , i will create Class for every email type (NewsLeterEmail,InvitationEmail,...) and create class maybe EmailCompoenet that take the URL and to, cc and just call send What do you think ?
Ahmed
Go ahead, I'll assist you if you need help.
Vivek Bernard