1

I have a form handle with angular that users populate for their application. It works fine, I use the Mandrill API to send the e-mail like this:

var m = new mandrill.Mandrill('your_api_key'); // This will be public

function sendTheMail(){
    m.messages.send({
        "message": {
            "from_email": "your_email_address",
            "from_name": "your_name",
            "to":[{"email": "someone's_email_address", "name": "someone's_name"}], // Array of recipients
            "subject": "optional_subject_line",
            "text": "Text to be sent in the body" // Alternatively, use the "html" key to send HTML emails rather than plaintext
        }
    });
}

Now I'd like to enable users to add a pdf attachment to their application. I can limit the format to PDF and the size to be relatively small.

What is the simplest way to do so? Do I need to add a module like https://github.com/nervgh/angular-file-upload?

Many thanks

Spearfisher
  • 8,445
  • 19
  • 70
  • 124
  • mandrill supports `base64` attachment, so encode file to `base 64` and attach, it only support max of 25 MB. http://stackoverflow.com/questions/23025414/attach-files-to-mandrill-message-with-browse-button – Ebin Manuval Jun 22 '16 at 04:59

1 Answers1

0

make entry for attachments in your message Json , it's an array you can add more attachments. fields in attachments hash are "type"(string)=>the MIME type of the attachment, "name"(string)=>the file name of the attachment, "content"(string)=>the content of the attachment as a base64-encoded string.

"attachments": [
        {
            "type": "text/plain",
            "name": "myfile.txt",
            "content": "ZXhhbXBsZSBmaWxl"
        }
    ]
WAQAR SHAIKH
  • 141
  • 1
  • 6