Base64 images to gmail

前端 未结 7 1469
再見小時候
再見小時候 2020-11-28 06:20

I\'m generating some inline images for an email sent from the iPad. Looks great in all desktop email clients, but gmail doesn\'t seem to like the base64 image and it shows u

7条回答
  •  天涯浪人
    2020-11-28 07:02

    I test that gmail don support also raw data uri images (without base64) - I use this snippet to generate image (which then was send to gmail addres) - but images not show up :(

    To solve this issue you need to add images as attachements with cid and use that cid in img tags - more details here

    function convert() {
      let base64 = imageBase64.value.split('base64,')[1];
      let hex = [...atob(base64)].map(c => c.charCodeAt(0).toString(16).padStart(2, 0));
      let img = 'data:image/png,%' + hex.join('%');
    
      pic.src = img;
      msg.innerText = img;
    }
    Put your img base64 data uri here

    Result

提交回复
热议问题