I'm trying to send an email with inline image using javascript & gmail api. Here is my code
//Encoded meta-data
var encodedResponse = btoa(
"MIME-Version: 1.0\n"+
"Date: Fri, 3 Feb 2017 16:26:20 +0530\n"+
"Subject: Test 3\n"+
"From: test@gmail.com\n"+
"To: test@gmail.com\n"+
"Content-Type: multipart/alternative; boundary=047d7b10cd77be159b05479e2150\n"+
"--047d7b10cd77be159b05479e2150\n"+
"Content-Type: text/plain; charset=UTF-8\n"+
"Test123\n\n"+
"--047d7b10cd77be159b05479e2150\n"+
"Content-Type: text/html; charset=UTF-8\n"+
'<div dir="ltr"><img src="http://www.desicomments.com/dc3/12/369547/369547.jpg" width="294" height="454"><br><div>Test123</div></div>\n'+
"--047d7b10cd77be159b05479e2150--"
).replace(/\+/g, '-').replace(/\//g, '_');
//Send Request
var sendRequest = gapi.client.gmail.users.messages.send({
'userId': 'me',
'resource': {
'raw': getEncodedMsg()
}
});
When I get this mail, the HTML part is not rendered at all. Pls check the screenshot below.
However "Show Original" displays the html content. Refer below:
Any idea why it's not rendered?
Additional Info: If I remove the src attribute content, then it renders the html part with image place holder.
'<div dir="ltr"><img src="" width="294" height="454"><br><div>Test123</div></div>\n'+