Html 使用href在电子邮件正文中添加图像

Html 使用href在电子邮件正文中添加图像,html,Html,我在我的页面中有一个链接,单击它将打开电子邮件客户端。 我的代码如下: <a href="mailto:?subject=Testing&body=AttachImage"> 我的问题是如何在邮件正文中添加图像。我尝试了图像src,但它不工作。有什么建议吗?在 希望能有所帮助。正在运行,您可能还没有定义img的宽度和高度 img{ 宽度:100px; 高度:100px; } 假设您将图像定义为: <img id="myimage" src="http://

我在我的页面中有一个链接,单击它将打开电子邮件客户端。 我的代码如下:

  <a href="mailto:?subject=Testing&body=AttachImage">


我的问题是如何在邮件正文中添加图像。我尝试了图像src,但它不工作。有什么建议吗?



希望能有所帮助。

正在运行,您可能还没有定义img的宽度和高度

img{
宽度:100px;
高度:100px;
}

假设您将图像定义为:

<img id="myimage" src="http://www.myserver.com/images/myimage"></img>
然后设置您的img src:

document["b64"].src = base64Image ;

这里提到的可能重复,根本不可能。但这并不能真正回答OP在这里提出的真正问题,是吗?我想我们的问题是在电子邮件客户端的电子邮件主体上渲染图像,而不是在DOM元素上。不过,有关此线程的解释可能会有所帮助-
<img id="b64" src=""></img>
function getBase64Image() {
    //return LOGO;
  var dataURL = '';
  try {
    var img = document.getElementById('myimage');
    // Create an empty canvas element
    var canvas = document.createElement("canvas");
    canvas.width = img.width;
    canvas.height = img.height;

    // Copy the image contents to the canvas
    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);

    // Get the data-URL formatted image
    // Firefox supports PNG and JPEG. You could check img.src to guess the
    // original format, but be aware the using "image/jpg" will re-encode the image.
    dataURL = canvas.toDataURL("image/jpg");
  }
  catch(e) {
    console.log('Could not retrieve Base64 image with userAgent : ' + navigator.userAgent + ' \nException : ' + e);
  }
  return dataURL;

}

var base64Image = getBase64Image();
document["b64"].src = base64Image ;