title: How to send an email with attachment using Gmail API in Node.js?
body: <p>I'm new to Node.js and I'm trying to create a mail box using the Gmail API everything works fine except uploading an attachment in email. I found examples with Java, Python and C#, yet I can't find any documentation with node about it. 
  Any tips would be very much appreciated.</p>
  
  <p>Here is my code:</p>
  
  
  
  <pre><code>function makeBody(to, from, subject, message) {
      var str = ["Content-Type: multipart/mixed; charset=\"UTF-8\"\n",
          "MIME-Version: 1.0\n",
          "Content-Transfer-Encoding: 7bit\n",
          "to: ", to, "\n",
          "from: ", from, "\n",
          "subject: ", subject, "\n\n",
          message,
          file
      ].join('');
  
      var encodedMail = new Buffer(str).toString("base64").replace(/\+/g, '-').replace(/\//g, '_');
  
      return encodedMail;
  }
  
  function sendMessage(auth) {
      var raw = makeBody(tap, 'me', response.subject, response.content, response.files);
      gmail.users.messages.send({
          auth: auth,
          userId: 'me',
          resource: {
              raw: raw
          }
      }, function (err, response) {
          if (err) {
              console.log('Error  ' + err);
              return;
          }
  
          if (response) {
              res.sendFile(__dirname + '/boite.html')
          }
      });
  }
  </code></pre>