mailto用法

如何使用mailto?
1)基本用法
< a href = mailto:sample@ 163 .com > send email < / a>
或者
< form action = " mailto:[email protected] " >


< / form>

mailto后跟的是收信人。
可使用参数列表
to 收信人
suject 主题
cc 抄送
bcc 暗抄送
body 内容
参数传递方式同页面之间传递值一样,可以使用查询字符串,也可以用form
querystring方式:
< a href = " mailto:[email protected][email protected]&body=use mailto sample " > send mail < / a>
form方式
< form name = ' sendmail '  action = ' mailto:[email protected] ' >
< input name = ' cc '  type = ' text '  value = ' [email protected] ' >
< input name = ' subject '  type = ' text '  value = ' test ' >
< input name = ' body '  type = ' text '  value = ' use mailto sample ' >
< / form>
两种方式同样传递所有参数。
2)示例说明
DOCTYPE HTML PUBLIC  " -//W3C//DTD HTML 4.0 Transitional//EN " >
< HTML >
 
< HEAD >
  
< TITLE >  Send Email  < / TITLE>
   < META NAME = " Generator "  CONTENT = " EditPlus " >
  
< META NAME = " Author "  CONTENT = "" >
  
< META NAME = " Keywords "  CONTENT = "" >
  
< META NAME = " Description "  CONTENT = "" >
 
< / HEAD>
< script >
Date.prototype.toString
= function ()
{
    
var d = new Date();
    
var ret = d.getYear();
    
var m = d.getMonth()+1;
    ret
+=m.length>1?m:'0'+m;
    
var date= d.getDate();
    ret
+=date.length>1?date:'0'+date;
    
return ret;    
}

var  initSubject = ' test ' + new  Date().toString(),initTo = ' [email protected] ' ,initCC = ' [email protected] ' ,initBody = ' use mailto sample ' ;

function  submitHandler()
{
    
var subject = subText.value;
    
var to = toText.value;
    
var cc = ccText.value;
    
var body = bodyText.value;
    mailTo.href
="mailto:"+to+"?cc="+cc+"&subject="+subject+"&body="+body;
    mailTo.click();
}

function  init()
{
    subText.value
=initSubject;
    toText.value
=initTo;
    ccText.value
=initCC;
    bodyText.value
=initBody;
}

< / script>
< style >
.label
{font-weight:bold;postion:absolute;width:80px;}
.head
{font-color:black;font-weight:bold;}
.bd
{float:left;width:77px;font-weight:bold;}
< / style>
  < BODY onload = " init() " >
 
< div class = " head " > Use mailto Send Email < / div>
  < div >
 
< span class = " label " > Subject: < / span>
  < / div>
  < div >
 
< span class = " label " > To: < / span>
  < / div>
  < div >
 
< span class = " label " > CC: < / span>
  < / div>
  < div >
 
< span class = " bd " > Body: < / span>< / textarea >
  
< / div>
  < input name = " btSend "  type = " button "  value = " send email "  onclick = " submitHandler(); " >
 
< a href = " mailto: "  id = " mailTo " >< / a>
  < / BODY>
< / HTML>
运行示例
Use mailto Send Email
Subject:
To:
CC:
Body:

转载于:https://www.cnblogs.com/AganCN/archive/2008/02/26/1082879.html

你可能感兴趣的:(mailto用法)