Send pdf file as attachment


#1

Hi,
I’m creating a pdf file by using pdfMake. After creating it, I want to send it as a mail attachment. How can I do this? I’m having the path of the file as I download this file into the phone storage of android as well as iphone.


#2

Are you using any plugin to send emails?

I use this one: http://ngcordova.com/docs/plugins/emailComposer/
It’s simple and well documented.

There is an example on how configure the email and send attachments:

$cordovaEmailComposer.isAvailable().then(function() {
   // is available
 }, function () {
   // not available
 });

  var email = {
    to: 'max@mustermann.de',
    cc: 'erika@mustermann.de',
    bcc: ['john@doe.com', 'jane@doe.com'],
    attachments: [
      'file://img/logo.png',
      'res://icon.png',
      'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...',
      'file://README.pdf'
    ],
    subject: 'Cordova Icons',
    body: 'How are you? Nice greetings from Leipzig',
    isHtml: true
  };

 $cordovaEmailComposer.open(email).then(null, function () {
   // user cancelled email
 });

#3

Thanks for the reply but I don’t want to use the native email composer plugin. I want to send the email from backend.