title: How to send html gmail message through javascript gapi?
body: <p>I am trying to send email message using JavaScript Gmail API, but I cannot find how to do it.</p>
  
  <p>Well, I have code to send normal email message, but all html is displayed  like text.</p>
  
  <p>Here is code: </p>
  
  <pre><code>var email = "From: me\r\nTo: "+to+ "\r\nBcc: " +bcc+ "\r\nSubject: "+subject+"\r\n\r\nbody: " + content;
  </code></pre>
  
  <p>SEND MESSAGE WITH METADATA ONLY</p>
  
  <pre><code>function sendMessage(email,id) 
  {
      var base64EncodedEmail = btoa(unescape(encodeURIComponent(email))).replace(/\//g,'_').replace(/\+/g,'-');
      var request = gapi.client.gmail.users.messages.send({
                                                          'userId': 'me',
                                                          'resource': {
                                                                      'raw':    base64EncodedEmail
                                                                     }, 
  
  
                                                        });
      request.execute(callbacksend);
  }
  </code></pre>
  
  <p>When I have tried to set content type as html in response, I receieved an error response from server that I need to use upload method.</p>
  
  <p>Indeed, here - <a href="https://developers.google.com/gmail/api/v1/reference/users/messages/send" rel="nofollow">https://developers.google.com/gmail/api/v1/reference/users/messages/send</a></p>
  
  <p>Is said:
  Upload URI, for media upload requests:</p>
  
  <p>POST <a href="https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send" rel="nofollow">https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send</a></p>
  
  <p>but while trying to use 
      gapi.client.load('upload', 'v1', callback);
  or just trying to run <code>gapi.client.upload.gmail.users.messages.send</code>
  its not found...</p>
  
  <p>I have no idea how to perform such request, or another way to send html message from gmail. Perhaps  I need to try it from pure XMLHttprequest, but better to find the way to perform it from gapi.</p>
  
  <p>p.s I've made such request through google apps script:</p>
  
  <pre><code>GmailApp.sendEmail(&lt;recipient&gt;,'subject', &lt;message&gt;,{htmlBody:&lt;message&gt;, bcc:'test@gmail.com'});
  </code></pre>
  
  <p>But need to perform it with javascript.</p>
  
  <p>Thanks!</p>