title: JavaScript: create MIME message
body: <p>I have user interface to send message. User enters a subject, message body, emails to send, attaches some files. After submit I need to send message as MIME message, like this:</p>
  
  <pre><code>From: John Doe &lt;example@example.com&gt;
  MIME-Version: 1.0
  Content-Type: multipart/mixed;
          boundary="XXXXboundary text"
  
  This is a multipart message in MIME format.
  
  --XXXXboundary text 
  Content-Type: text/plain
  
  this is the body text
  
  --XXXXboundary text 
  Content-Type: text/plain;
  Content-Disposition: attachment;
          filename="test.txt"
  
  this is the attachment text
  
  --XXXXboundary text--
  </code></pre>
  
  <p>How can I gather user entered information as MIME message? I searched to build MIME message on client side with JavaScript but no success. If attachments exist, I need to convert them base64 string, then send within MIME message. Thanks.</p>