[英]Initiate Mail From Javascript
I have a button click event in jquery, Inside which I want to initiate my mailbox on it's click with a particular text as the mail's body that is stored in a variable. 我在jquery中有一个按钮点击事件,在里面我要启动我的邮箱,点击特定文本作为存储在变量中的邮件正文。
Following is my code: 以下是我的代码:
$('#myButton').click(function(){
$('#btnLaunchEmail').hide();
if (strExternalZippedLink.trim() != '') {
//Here I have to initiate the email
}
})
I tried a lot of things but didn't worked . 我尝试了很多东西,但没有奏效。 Can anyone help.
谁能帮忙。
Try Below code: 试试以下代码:
if (strExternalZippedLink.trim() != '') {
//Lunching the email
var aLink = document.createElement('a');
aLink.href = 'mailto:?body=' + strExternalZippedLink;
aLink.click();
}
strExternalZippedLink will be shown in the body strExternalZippedLink将显示在正文中
You need to use a mailto
URL. 您需要使用
mailto
URL。 Wiki article: http://en.wikipedia.org/wiki/Mailto 维基文章: http : //en.wikipedia.org/wiki/Mailto
$('#myButton').click(function(){
$('#btnLaunchEmail').hide();
if (strExternalZippedLink.trim() != '') {
var to = "someone@example.com";
var subject = "This is my subject";
var myBody = "This is the message body";
window.location = "mailto:" + to +"?subject=" + subject + "&body=" + myBody;
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.