【问题标题】:HTML2CANVAS image to be sent via email要通过电子邮件发送的 HTML2CANVAS 图像
【发布时间】:2015-07-06 13:44:21
【问题描述】:

这就是我想要达到的目标 当在 HTML 页面中的特定 div 上按下按钮时,它会转到 HTML2CANVAS 函数并创建画布 img。现在我需要将此图像附加到正文并打开一个 Outlook 撰写框。 1) 如何从网页中发送带有嵌入正文的图像的邮件? 2) 如何将canvas转换为可显示的图片?

【问题讨论】:

    标签: html mailto html2canvas


    【解决方案1】:
    1. 这个函数是你第二个问题的答案。此函数将 div 转换为 base64 图像,并在完成渲染时将图像显示为 div,或者您可以根据需要执行相应操作。

      function getImage(){
      
              html2canvas($("#divID"), {
                  onrendered: function(canvas) {
                      //  For image
                      var ctx=canvas.getContext("2d");
      //              ctx.webkitImageSmoothingEnabled = false;
      //              ctx.mozImageSmoothingEnabled = false;
                      ctx.imageSmoothingEnabled = false;
      
                      var convertedImage;
                      $.when(convertedImage = canvas.toDataURL('image/jpg')).promise().done(function(){
      
          $('#finalImg').prop('src', convertedImage)              
                      });  
                  }
      
              });                     
      
      }
      
    2. 你的第一个问题的答案也是一样的,这个转换后的图像可以作为图像发送到邮件中。

    3. 但是您不能在 mailto body 中发送 MIME 类型,它只能包含纯文本作为正文。 供进一步参考这里是一个链接 Sending mail from HTML page with image in the body

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 2018-04-08
      • 1970-01-01
      • 2022-08-18
      • 1970-01-01
      • 2017-03-30
      相关资源
      最近更新 更多