title: Angular 2 - Send base64 item as attachment of email
body: <p>For a project I'm working on, I need to be able to sent a <code>pdf</code>, which is freshly generated using <code>jsPDF</code>, as a attachment of a e-mail. Right now, my code looks similar to this:</p>
  
  <pre><code>import * as jsPDF from 'jspdf';
  
  export class pdfService {
    generatePDF () {
      let pdf = new jsPDF('p', 'pt', 'a4');
      pdf.text('hello', 20, 20);
      let attachment = pdf.output('datauristring');
      window.open("mailto:example@domain.com?subject=Test&amp;body=Test&amp;attachments='" + attachment + "'");
    }
  }
  </code></pre>
  
  <p>The <code>window.open</code> will open a new window and my cursor changes from a normal arrow to a loading arrow, which I guess would mean Windows is trying to open Outlook but it fails to do so.</p>
  
  <p>Now, of course, <code>pdf.output('datauristring')</code> returns <code>base64</code>. I guess that would be the problem I'm facing here.</p>
  
  <p>So my actual question is, how can I send a newly generated pdf as a attachment of a email?</p>
  
  <p><strong>Edit:</strong>
  I just found out the base64 string is too long. The max url length is 2048 but the base64 string is over 15,000 characters long. Is it possible to shorten the length of it?</p>