I have a div which contains some html that I want to use as an email template. I first successfully created my function to add a draft email with a plain text but when I try to create the draft using the div html contents something breaks. So I then attempted to use base64 encode the div contents and create a draft just put the encoded string in the body of the email instead of being decoded back into my html. So no I am at a loss and was wondering if anybody had any thoughts on what I'm doing wrong.
function sendMessage(headers_obj, message, callback)
{
var email = '';
for(var header in headers_obj)
email += header += ": "+headers_obj[header]+"\r\n";
newmessage = Base64.encodeURI(message);
email += "\r\n" + newmessage;
email = window.btoa(email).replace(/\+/g, '-').replace(/\//g, '_');
gapi.client.load('gmail', 'v1', function() {
var request = gapi.client.gmail.users.drafts.create({
'userId': "me",
'resource': {
'message': {
'raw': email
},
}
});
request.execute(function(callback){
console.log(callback)
});
});
}