onclick on button outlook email应该使用Javascript或使用锚标记打开

时间:2016-07-28 06:19:53

标签: javascript html email xslt href

尝试使用html但电子邮件内容部分也有变量..比如必须显示他/她的联系电话或注册号,我不能在电子邮件模板中硬编码,所以如果我使用JavaScript并尝试使用文本区域 我怎样才能在其中使用变量?

<textarea id="myText" style="display:none">

function sendMail(){
    var link = "mailto:me@example.com"
        + "?cc=myCCaddress@example.com"
        + "&subject=" + escape("This is my subject")
        + "&body=" + escape(document.getElementById('myText').value);`

    window.location.href = link;
}

1 个答案:

答案 0 :(得分:1)

尝试使用Anchor Tag Direct Open Outllook

<a href="mailto:name1@rapidtables.com?cc=name2@rapidtables.com&bcc=name3@rapidtables.com
&amp;subject=The%20subject%20of%20the%20email
&amp;body=The%20body%20of%20the%20email">
Send mail with cc, bcc, subject and body</a>

Demo Link

使用Javscript

function Setemail(mailto,cc,bcc,subjcet,body,Title)
{
 var email='<a href="mailto:'+mailto+'?cc='+mailto+'&bcc='+bcc+'&amp;subject='+subjcet'&amp;body='+body+'">'
+Title+'</a>';
}