Web Template Example

We templates are just file template but you specify a web address instead of a server address. Great if your templates are on a different server.

Using a file as a template is an easy way to send automated emails. You may want to send each user a welcome email when they sign up but change the details in the email.

Templates are just a simple file with text or HTML inside (you need both an HTML and a plain text one).

You can see our example templates below;

You can also specify placeholders in your template which can then be replaced with content later.

For example you may put "Dear {Username}" which would become "Dear Tim" once you've added your content.

Example

Contact Form
To
From
Subject
Send Type


Step By Step For Mandrill

Step 1

First you need to follow the guide for integrating the DLL and setting up Easy Email at Setting Up.

Next all that is required is the below code, placed inside the click handler of the send button.

//Create the recipient
EasyEmailForMandrill.Recipient recipient =
new EasyEmailForMandrill.Recipient(txtTo.Text);

//Create a content list to replace the place holders in the template
List<EasyEmail.EmailContent> content = new List<EasyEmail.EmailContent>();
            
//Now we can add some content to the content list
content.Add(
    new EasyEmail.EmailContent("{Content1}",
    "This replaces the place holder that said {Content1} with this text.")
    );
content.Add(
    new EasyEmail.EmailContent("{Content2}",
    "This replaces the place holder that said {Content2} with this text.")
    );

//Here we set the web addresses of the templates
string htmlTemplateWebPath =
    "http://easyemailformandrill.azurewebsites.net/Templates/HTML.html";
string plainTextTemplateWebPath =
    "http://easyemailformandrill.azurewebsites.net/Templates/PlainText.txt";

EasyEmailForMandrill.MandrillEmail email =
    new EasyEmailForMandrill.MandrillEmail(
        recipient,
        txtFrom.Text,
        txtSubject.Text,
        plainTextTemplateWebPath,
        htmlTemplateWebPath,
        EasyEmailForMandrill.Constants.TemplatePathType.URI);

//Next we attach the content
email.AddContent(content);

//We then send the email and get a EasyEmailResponse back
EasyEmail.EasyEmailResponse response = email.Send();

//Finally we display the EasyEmailResponse message
lblOut.Text = "Easy Email response : " + response.Message;
            

Completed!

That's all you need to do to send an email from a web template with Easy Email For Mandrill

Step By Step For SMTP

Step 1

First you need to follow the guide for integrating the DLL and setting up Easy Email at Setting Up.

Next all that is required is the below code, placed inside the click handler of the send button.

//Create a content list to replace the place holders in the template
List<EasyEmail.EmailContent> content = new List<EasyEmail.EmailContent>();
            
//Now we can add some content to the content list
content.Add(
    new EasyEmail.EmailContent("{Content1}",
    "This replaces the place holder that said {Content1} with this text.")
    );
content.Add(
    new EasyEmail.EmailContent("{Content2}",
    "This replaces the place holder that said {Content2} with this text.")
    );

//Here we set the web addresses of the templates
string htmlTemplateWebPath =
    "http://easyemailformandrill.azurewebsites.net/Templates/HTML.html";
string plainTextTemplateWebPath =
    "http://easyemailformandrill.azurewebsites.net/Templates/PlainText.txt";

//Now we create the EasyEmail object
EasyEmail.EmailMessage email =
    new EasyEmail.EmailMessage(
        txtTo.Text,
        txtFrom.Text,
        txtSubject.Text,
        plainTextTemplateWebPath,
        htmlTemplateWebPath,
        EasyEmail.Constants.TemplatePathType.URI);

//Next we attach the content
email.AddContent(content);

//We then send the email and get a EasyEmailResponse back
EasyEmail.EasyEmailResponse response = email.Send();

//Finally we display the EasyEmailResponse message
lblOut.Text = "Easy Email response : " + response.Message;
            

Completed!

That's all you need to do to send an email from a web template with Easy Email For Mandrill