简体   繁体   English

单击“通过邮件发送”按钮时如何在邮件正文中嵌入图像

[英]How to embed an image at mail body when clicking “send by mail” button

I have a list of social sharing buttons on HTML. 我有一个HTML上的社交共享按钮列表。 Clicking each of them allows to send an image (see the codepen sample). 单击它们中的每一个都可以发送图像(请参阅codepen示例)。 I would like to know if there's a way to attach the same image on the "Sending by mail" button, at the mail body. 我想知道是否可以在邮件正文的“通过邮件发送”按钮上附加相同的图像。

Thanks 谢谢

codepen sample 码笔样本

 .FCBK, .TWITTER, .GPLUS, .MAIL { position: absolute; display:block; top:0; right:0; margin-top:5px; text-indent:-9999px; width:50px; height:50px; background-repeat:no-repeat; cursor: pointer; } .FCBK { background-image: url(http://www.myrtlebeachgolf.com/assets/images/facebook-icon.png); margin-right: 203px; } .TWITTER { background-image: url(http://www.myrtlebeachgolf.com/assets/images/twitter-icon.png); margin-right:141px; } .GPLUS { background-image: url(http://www.myrtlebeachgolf.com/assets/images/google-plus-icon.png); margin-right:79px; } .MAIL { background-image: url(http://www.myrtlebeachgolf.com/assets/images/email-icon.png); margin-right:17px; } 
 <div class="SOCIAL"> <a class="FCBK" rel="img_src" href="" onclick="popUp=window.open( 'https://www.facebook.com/sharer.php?u=http://www.designboom.com/contest/files/copy_0_brain1.jpg', 'popupwindow', 'scrollbars=yes,width=800,height=400'); popUp.focus(); return false" title="Share on Facebook"> <!--<i class="visuallyhidden">share on facebook</i>--> </a> <a class="TWITTER" rel="nofollow" href="https://twitter.com/" onclick="popUp=window.open( 'https://twitter.com/intent/tweet?text=pic.twitter.com/HntZUf55tt', 'popupwindow', 'scrollbars=yes,width=800,height=400'); popUp.focus(); return false" title="Share on Twitter"> <!-- <i class="visuallyhidden">share on twitter</i>--> </a> <a class="GPLUS" rel="nofollow" href="https://www.plus.google.com/" onclick="popUp=window.open( 'https://plus.google.com/share?url=http://www.designboom.com/contest/files/copy_0_brain1.jpg', 'popupwindow', 'scrollbars=yes,width=800,height=400'); popUp.focus(); return false" title="Share on Google+"> <!--<i class="visuallyhidden">share on google plus</i>--> </a> <a class="MAIL" rel="nofollow" href="mailto:?subject=I like this &body=http://www.designboom.com/contest/files/copy_0_brain1.jpg" title="Send by mail"> <!--<i class="visuallyhidden">share via email</i>--> </a> </div> 

As far I know the only way to achieve this is by using Base64 encoded images. 据我所知,实现此目标的唯一方法是使用Base64编码的图像。 See this answer: 看到这个答案:

Sending mail from HTML page with image in the body 从正文中带有图像的HTML页面发送邮件

Please keep in mind that you cannot use spaces as character. 请记住,您不能使用空格作为字符。 Email content have to be entity encoded. 电子邮件内容必须是实体编码的。 Otherwise some characters will break your code. 否则,某些字符会破坏您的代码。 Just use %20 instead of space. 只需使用%20代替空格。 For further experiments with encoding you could try This online encoder 有关编码的进一步实验,您可以尝试使用此在线编码器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM