uexEmail对象封装了用于调用系统邮件功能进行邮件的发送。
使用示例
以下示例代码说明了如何使用uexEmail对象的方法。
<!DOCTYPE html>
<html>
<head>
<title>AppCan API uexEmail</title>
<meta charset='utf-8'>
<script>
window.uexOnload = function(type){
if(!type){
uexWidgetOne.onError=function(opCode,errorCode,errorDesc){
console.log(errorCode+':'+errorDesc);
}
}
}
function $$(id){
return document.getElementById(id);
}
function openBrowser(){
uexImageBrowser.cbPick=function (opCode,dataType,data){
var val = $$('attachmentPath').value;
$$('attachmentPath').value = val?(val+','+data):data;
/*
* 多附件发送,支持邮件附件路径的协议,数据格式数组和字符串都支持,
* 如:var str = ‘wgt://1.png,wgts://’;(逗号必须为英文字符)
* */
}
uexImageBrowser.pick();
}
function sendEmail(){
var receiverEmail = $$('receiverEmail').value;
var subject = $$('subject').value;
var content = $$('content').value;
var attachmentPath = $$('attachmentPath').value;
uexEmail.open(receiverEmail, subject, content, attachmentPath);
}
function sendEmailMulti(){
/*
* 若多人发送,接收者的邮件地址数据格式数组和字符串都支持,
* 如:var str = ‘123@qq.com,123@163.com’;(逗号必须为英文字符)
* */
var receiverEmail = $$('receiverEmail').value;
console.log(receiverEmail);
var subject = $$('subject').value;
var content = $$('content').value;
var attachmentPath = $$('attachmentPath').value;
console.log(attachmentPath);
uexEmail.open(receiverEmail, subject, content, attachmentPath);
}
</script>
</head>
<body>
<div>
<span>输入收件人</span>
<input type='text' id='receiverEmail' value=''>
<br>
<span>输入邮件主题</span>
<input type='text' id='subject' value=''>
<br>
<span>输入邮件内容</span>
<input type='textarea' id='content' value=''>
<br>
<span>添加附件</span>
<input type='text' value='' id='attachmentPath' >
<input type='button' value='浏览' onClick='openBrowser();' >
<br>
<input type='button' value='发送1人' onclick='sendEmail();'>
<br>
<input type='button' value='发送多人' onclick='sendEmailMulti();'>
</div>
</body>
</html>
使用示例
以下示例代码说明了如何使用uexEmail对象的方法。
<!DOCTYPE html>
<html>
<head>
<title>AppCan API uexEmail</title>
<meta charset='utf-8'>
<script>
window.uexOnload = function(type){
if(!type){
uexWidgetOne.onError=function(opCode,errorCode,errorDesc){
console.log(errorCode+':'+errorDesc);
}
}
}
function $$(id){
return document.getElementById(id);
}
function openBrowser(){
uexImageBrowser.cbPick=function (opCode,dataType,data){
var val = $$('attachmentPath').value;
$$('attachmentPath').value = val?(val+','+data):data;
/*
* 多附件发送,支持邮件附件路径的协议,数据格式数组和字符串都支持,
* 如:var str = ‘wgt://1.png,wgts://’;(逗号必须为英文字符)
* */
}
uexImageBrowser.pick();
}
function sendEmail(){
var receiverEmail = $$('receiverEmail').value;
var subject = $$('subject').value;
var content = $$('content').value;
var attachmentPath = $$('attachmentPath').value;
uexEmail.open(receiverEmail, subject, content, attachmentPath);
}
function sendEmailMulti(){
/*
* 若多人发送,接收者的邮件地址数据格式数组和字符串都支持,
* 如:var str = ‘123@qq.com,123@163.com’;(逗号必须为英文字符)
* */
var receiverEmail = $$('receiverEmail').value;
console.log(receiverEmail);
var subject = $$('subject').value;
var content = $$('content').value;
var attachmentPath = $$('attachmentPath').value;
console.log(attachmentPath);
uexEmail.open(receiverEmail, subject, content, attachmentPath);
}
</script>
</head>
<body>
<div>
<span>输入收件人</span>
<input type='text' id='receiverEmail' value=''>
<br>
<span>输入邮件主题</span>
<input type='text' id='subject' value=''>
<br>
<span>输入邮件内容</span>
<input type='textarea' id='content' value=''>
<br>
<span>添加附件</span>
<input type='text' value='' id='attachmentPath' >
<input type='button' value='浏览' onClick='openBrowser();' >
<br>
<input type='button' value='发送1人' onclick='sendEmail();'>
<br>
<input type='button' value='发送多人' onclick='sendEmailMulti();'>
</div>
</body>
</html>