如何实现网页发送邮件的功能

dim str
str=str&"您好!"
str=str&"  dgdggg。"
str=str&"dgfdgdgdgg!
"
str=str&"  dgdgggfgf。
"
str=str&"  dgdgg" str=str&"dgdsgdgg。
"
str=str&"  dgdggg" str=str&"dgdgdgdgg。
"
str=str&"  dgdgggg!
"
str=str&"  dfggdg
"
str=str&" bbbbbbbbbbb
"
str=str&" aaaaaaaaaaa
"
filename="test.gif" "附件文件名
path=Server.MapPath("jefenetimages" & filename) "附件的路径
Set theMail=Server.CreateObject("CDONTS.NewMail")
theMail.From="test@263.net"   "发件人信箱
theMail.To ="test@21cn.com"   "收件人信箱
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
—————————————————————

 

onsubmit="return FrontPage_MayorMailBox_Validator(this)"
action=sendmail.asp method=post>

 

发 信 人 姓 名 : <input tabindex="1" maxlength="16" size="16&lt;br" type="text" /> name=AddresserName&gt;

&nbsp;

发信人Email地址: <input tabindex="2" maxlength="40" size="30&lt;br" type="text" /> name=AddresserEmailAddress&gt;

&nbsp;

发信人联系电话 : <input tabindex="3" name="AddresserTelNo" size="15" type="text" />

&nbsp;

发信人联系地址 : <input tabindex="4" name="AddresserAddress" size="50" type="text" />

&nbsp;

发信人邮政编码 : <input tabindex="5" name="AddresserPostalCode" size="6" type="text" />

&nbsp;

收信人:<select tabindex="6" name="AddresseeName" size="1">&lt;OPTION
</select>
<select tabindex="6" name="AddresseeName" size="1">value="beijing@beijing.com" selected&gt;北京市政府 &lt;OPTION
</select>
<select tabindex="6" name="AddresseeName" size="1">value="beijing@beijing.com"&gt;代理市长王岐山
<option value="beijing@beijing.com">王岐山副市长</option>
</select>
<select tabindex="6" name="AddresseeName" size="1">
<option value="beijing@beijing.com">刘敬民副市长</option>
<option value="beijing@beijing.com">张茅副市长</option>
</select>
<select tabindex="6" name="AddresseeName" size="1">
<option value="beijing@beijing.com">翟鸿祥副市长</option>&lt;OPTION
</select>
<select tabindex="6" name="AddresseeName" size="1">value="beijing@beijing.com"&gt;刘志华副市长
<option value="beijing@beijing.com">孙安民副市长</option>
</select>
<select tabindex="6" name="AddresseeName" size="1">
<option value="范伯元">范伯元副市长</option>&lt;OPTION
</select>
<select tabindex="6" name="AddresseeName" size="1">value="beijing@beijing.com"&gt;牛有成副市长
<option value="beijing@beijing.com">陆昊副市长</option>
</select>

&nbsp;

标 题: <input tabindex="7" maxlength="50" name="MailSubject" size="44" type="text" />
(最多25个汉字)

&nbsp;
<div align="center">
<big><strong>正  文:
</strong></big><textarea tabindex="8" cols="74" name="MailContext" rows="10"></textarea>

</div>
&nbsp;
<div align="center">
<input tabindex="9" name="Action" type="submit" value="提交" />    <input tabindex="10" name="ResetButton" type="reset" value="重来" />

</div>
&nbsp;
<div align="center"></div>
senmail.asp

&lt;%
name=Request.Form("AddresserName")
email= Request.Form("AddresserEmailAddress")
tel=Request.Form ("AddresserTelNo")
add= Request.Form("AddresserAddress")
zip= Request.Form("AddresserPostalCode")
to1= Request.Form("AddresseeName")
subj= Request.Form("MailSubject")
cont= Request("MailContext")

set webmail=server.createobject("cdonts.newmail")
webmail.to=to1
webmail.from=email
webmail.subject=subj
webmail.body=cont
webmail.send
set webmail=nothing
response.write "发送成功
"
%&gt;
—————————————————————

&lt;%
dim CLStr,msg,mailserver,username,password,receive
mailserver="mail.tjzero.com"
username="zhong@tjzero.com"
password="12345"
receive="wbc@tjzero.com"

Set msg = Server.CreateObject("JMail.Message")
msg.silent = true
msg.Logging = true
msg.Charset = "gb2312"
msg.MailServerUserName = username
msg.MailServerPassword = password
msg.From = username
msg.FromName = username
msg.AddRecipient (receive)
msg.Subject = "xx"
msg.send(mailserver)

msg.Body = "sss"
msg.close
set msg = nothing
%&gt;

コメントを残す

メールアドレスが公開されることはありません。