Headers Example

Sometimes you may need to add headers to your emails, this is a more advanced feature that most people won't need but with Easy Email you can add any header you like.

Adding headers is easy, simply use the AddHeader method and specify your header name and header value.

Example

Contact Form
To
From
Subject
Message
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.

protected void btnSend_Click(object sender, EventArgs e)
{
    //Create the recipient
  EasyEmailForMandrill.Recipient recipient =
  new EasyEmailForMandrill.Recipient(txtTo.Text);

    EasyEmailForMandrill.MandrillEmail email = 
    new EasyEmailForMandrill.MandrillEmail( recipient, 
                                            txtFrom.Text, 
                                            txtSubject.Text, 
                                            txtMessage.Text);

    email.AddHeader(new EasyEmail.EmailHeader("X-Mailer","EasyEmail"));
    EasyEmail.EasyEmailResponse response = email.Send();

    lblOut.Text = "Easy Email response : " + response.Message;
}
            

Completed!

That's all you need to do to send an email with custom headers 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.

protected void btnSend_Click(object sender, EventArgs e)
{
   EasyEmail.EmailMessage email = 
   new EasyEmail.EmailMessage(txtTo.Text, txtFrom.Text,
   txtSubject.Text, txtMessage.Text);
   email.AddHeader(new EasyEmail.EmailHeader("X-Mailer","EasyEmail"));
    EasyEmail.EasyEmailResponse response = email.Send();

    lblOut.Text = "Easy Email response : " + response.Message;
}
            

Completed!

That's all you need to do to send an email with custom headers with Easy Email For Mandrill