node.js - base64 images not displaying in Outlook when using ejs + emailjs -


i'm using mix of ejs , emailjs send out emails in node.js app when various events happen. i'd embed base64 image (a small logo) email when sends, both outlook , gmail (plus inbox google) fail render image.

i'm using bit of code find mime type of image , put base64 string:

myapp.prototype.imagetobase64 = function(image) {   var mime = require("mime")   file = fs.readfilesync(__dirname + "/images/" + image, { encoding: 'base64'})   return 'data:' + mime.lookup(image) + ';base64,' + file; } 

that works great, because i'm able copy , paste resulting string right browser , see image. when send email via emailjs, outlook converts +s +. when "view original" in gmail, base64 split 'chunks'. each chunk on newline , each line ends =. if take gmail's version , remove = , newline paste browser, whole picture loads perfectly, refuses load anywhere else, regardless of whether user in contact list or not.

here's code i'm using send email:

// host, username, password , ssl (false) set above here server.send({     text: mytemplate,     from: "me@example.com",     to: "someone@example.com",     subject: "testing",     attachment: [      {data:mytemplate, alternative:true}     ]   }) 

and template looks (truncated, other bits aren't important):

  <body>     <p><img src="<%- imagetobase64("logo.png") %>"></p>     <h1><%= name %> has been triggered</h1>     <p><%= name %> has been triggered. triggered on <%= thedate %></p> 

any hints?

edit: tried setting headers in "attachment" property, no luck

outlook uses word render images, , word not support embedded (src="data:image") images.

you need attach image file , set content-id mime header value matching cid attribute on image (<img src="cid:xyz">) in html body.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -