【问题标题】:How to embed an image at mail body when clicking "send by mail" button单击“通过邮件发送”按钮时如何在邮件正文中嵌入图像
【发布时间】:2017-01-29 20:58:11
【问题描述】:

我有一个 HTML 上的社交分享按钮列表。单击它们中的每一个都可以发送图像(请参阅 codepen 示例)。我想知道是否有办法在邮件正文的“通过邮件发送”按钮上附加相同的图像。

谢谢

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>

【问题讨论】:

    标签: html social


    【解决方案1】:

    据我所知,实现此目的的唯一方法是使用 Base64 编码图像。看到这个答案:

    Sending mail from HTML page with image in the body

    请记住,您不能使用空格作为字符。电子邮件内容必须是实体编码的。否则某些字符会破坏您的代码。只需使用%20 而不是空格。如需进一步的编码实验,您可以尝试This online encoder

    【讨论】:

    • 谢谢,我去看看。
    • 据我所知是不可能的:-(
    • @Danielillo 请记住,您不能使用空格作为字符。这破坏了代码。只需使用“%20”而不是空格;)
    • Muchas%20gracias!
    • @Danielillo De nada ;) 但如果这有帮助,你可以投票给答案...
    猜你喜欢
    • 2012-06-23
    • 2012-03-10
    • 2021-10-09
    • 1970-01-01
    • 2011-11-14
    • 1970-01-01
    • 1970-01-01
    • 2011-01-09
    • 2017-02-09
    相关资源
    最近更新 更多