Attachment Example

Attachments are an important part of sending emails, they allow you to add files like invoices and videos to emails.

Using Easy Emails makes it really easy to send your customers their PDF invoices or sales confirmations as well as any digital products you sell.

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 add the following code to the click event of your send button, or in the code where you want to send the email.

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

//Create a new email class
EasyEmailForMandrill.MandrillEmail email =
    new EasyEmailForMandrill.MandrillEmail(
        recipient,
        txtFrom.Text,
        txtSubject.Text,
        txtMessage.Text
        );
            
//To make things easy we map the path to the files
string exampleInvoicePath =
    Server.MapPath("~/Attachments/ExampleInvoice.pdf");
string exampleSalesInformation =
    Server.MapPath("~/Attachments/ExampleSalesInformation.pdf");
 
//Add the attachments to the email
email.AddAttachment(exampleInvoicePath);
email.AddAttachment(exampleSalesInformation);

//Send the email
EasyEmail.EasyEmailResponse response = 
    email.Send();

//Show the response
lblOut.Text = 
    "Easy Email response : " + response.Message;
            

Completed!

That's all you need to do to send an email with an attachment 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 add the following code to the click event of your send button, or in the code where you want to send the email.

//Create a new email class
EasyEmail.EmailMessage email = 
    new EasyEmail.EmailMessage(
        txtTo.Text, 
        txtFrom.Text, 
        txtSubject.Text, 
        txtMessage.Text
        );
            
//To make things easy we map the path to the files
string exampleInvoicePath =
    Server.MapPath("~/Attachments/ExampleInvoice.pdf");
string exampleSalesInformation =
    Server.MapPath("~/Attachments/ExampleSalesInformation.pdf");
 
//Add the attachments to the email
email.AddAttachment(exampleInvoicePath);
email.AddAttachment(exampleSalesInformation);

//Send the email
EasyEmail.EasyEmailResponse response = 
    email.Send();

//Show the response
lblOut.Text = 
    "Easy Email response : " + response.Message;
            

Completed!

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