本人网页中需要将用户填写的内容用邮件的方式自动发送出去,请问如何实现?如果需要使用ASP来编写,请问编写的内容如何触发?也就是当点击网页上“发送邮件”的图标时,相关代码应该写在什么地方?本人是个HTML菜鸟,不知道HTML对消息驱动是怎么个处理的,或者干脆就没有这么个概念?
---------------------------------------------------------------
http://www.aspsky.net/article/index.asp?classid=2&Nclassid=32
---------------------------------------------------------------
dim str
str=str&"您好!"
str=str&" dgdggg。"
str=str&"dgfdgdgdgg!
1<br/>
"
str=str&" dgdgggfgf。
1<br/>
"
str=str&" dgdgg" str=str&"dgdsgdgg。
1<br/>
"
str=str&" dgdggg" str=str&"dgdgdgdgg。
1<br/>
"
str=str&" dgdgggg!
1<br/>
"
str=str&" dfggdg
1<br/>
"
str=str&" bbbbbbbbbbb
1<br/>
"
str=str&" aaaaaaaaaaa
1<br/>
"
filename="test.gif" "附件文件名
path=Server.MapPath("\jefenet\images" & filename) "附件的路径
Set theMail=Server.CreateObject("CDONTS.NewMail")
theMail.From="[email protected]" "发件人信箱
theMail.To ="[email protected]" "收件人信箱
theMail.Subject ="电子邮件功能测试!" "主题
theMail.BodyFormat=0 "定义以Html的格式发送邮件
theMail.MailFormat=0 "定义以Mime的格式发邮件
theMail.Body=Str "邮件正文
On Error Resume Next "如果找不到附件,则跳过
theMail.AttachFile path,filename
theMail.Send
set theMail=nothing
---------------------------------------------------------------
1<form action="sendmail.asp" method="post" name="MayorMailBox" onsubmit="return FrontPage_MayorMailBox_Validator(this)">
2<p>发 信 人 姓 名 : <input maxlength="16" name="AddresserName" size="16" tabindex="1"/> </p>
3<p>发信人Email地址: <input maxlength="40" name="AddresserEmailAddress" size="30" tabindex="2"/> </p>
4<p>发信人联系电话 : <input name="AddresserTelNo" size="15" tabindex="3"/> </p>
5<p>发信人联系地址 : <input name="AddresserAddress" size="50" tabindex="4"/> </p>
6<p>发信人邮政编码 : <input name="AddresserPostalCode" size="6" tabindex="5"/> </p>
7<p>收信人: <select name="AddresseeName" size="1" tabindex="6"> <option selected="" value="[email protected]">北京市政府</option> <option value="[email protected]">代理市长王岐山</option> <option value="[email protected]">王岐山副市长</option>
8<option value="[email protected]">刘敬民副市长</option> <option value="[email protected]">张茅副市长</option>
9<option value="[email protected]">翟鸿祥副市长</option> <option value="[email protected]">刘志华副市长</option> <option value="[email protected]">孙安民副市长</option>
10<option value="范伯元">范伯元副市长</option> <option value="[email protected]">牛有成副市长</option> <option value="[email protected]">陆昊副市长</option></select>
11</p>
12<p>标 题: <input maxlength="50" name="MailSubject" size="44" tabindex="7"/>
13(最多25个汉字)</p>
14<div align="center">
15<p><big><strong>正 文:<br/></strong></big><textarea cols="74" name="MailContext" rows="10" tabindex="8"></textarea>
16</p></div>
17<div align="center">
18<p><input name="Action" tabindex="9" type="submit" value="提交"/> <input name="ResetButton" tabindex="10" type="reset" value="重来"/> </p></div>
19<div align="center"></div>
20</form>
senmail.asp
1
2name=Request.Form("AddresserName")
3email= Request.Form("AddresserEmailAddress")
4tel=Request.Form ("AddresserTelNo")
5add= Request.Form("AddresserAddress")
6zip= Request.Form("AddresserPostalCode")
7to1= Request.Form("AddresseeName")
8subj= Request.Form("MailSubject")
9cont= Request("MailContext")
10
11set webmail=server.createobject("cdonts.newmail")
12webmail.to=to1
13webmail.from=email
14webmail.subject=subj
15webmail.body=cont
16webmail.send
17set webmail=nothing
18response.write "发送成功
19"
---------------------------------------------------------------
1
2dim CLStr,msg,mailserver,username,password,receive
3mailserver="mail.tjzero.com"
4username="[email protected]"
5password="12345"
6receive="[email protected]"
7
8Set msg = Server.CreateObject("JMail.Message")
9msg.silent = true
10msg.Logging = true
11msg.Charset = "gb2312"
12msg.MailServerUserName = username
13msg.MailServerPassword = password
14msg.From = username
15msg.FromName = username
16msg.AddRecipient (receive)
17msg.Subject = "xx"
18msg.send(mailserver)
19
20
21msg.Body = "sss"
22msg.close
23set msg = nothing