在ASP中用EasyMailObject组件处理Exchange邮件源代码---发送邮件(p_sendmail.asp)
1@ Language=VBScript
1
2'*************************************
3
4'这个文件用来发送邮件
5'作者:awayeah
6'邮箱:[email protected]
7
8'*************************************
9
10if session("straccount")="" or session("strpassword")="" then
11Response.End
12end if
1<html>
2<head>
3<meta content="Microsoft Visual Studio 6.0" name="GENERATOR"/>
4</head>
5<style>
6<!--
7A{text-decoration:none}
8\-->
9</style>
10<body>
Set SMTP = CreateObject("EasyMail.SMTP.5")
SMTP.LicenseKey = "awa/S19I500R1AX30C0R3100"
SMTP.MailServer = "192.9.200.89"
SMTP.Subject = Request.Form("subject")
SMTP.BodyText = Request.Form("bodytext")
SMTP.From = Request.Form("from")
SMTP.FromAddr = Request.Form("fromaddr")
SMTP.AddRecipient Request.Form("from"), Request.Form("receive1") , 1
'添加附件
if Request.Form("att")="" then
Response.Write ""
else
x = SMTP.AddAttachment(Request.Form("att"), 0)
If Not x = 0 Then
Response.Write "插入附件错误: " + cstr(x) + "请与管理员联系。"
End If
end if
x = SMTP.Send
If x = 0 Then
' Response.Write ("<p align="center"><br/><br/>")
' Response.Write ("<font <p="" align="center" size=")
Response.Write "><br/><br/><b><font color="#00FFFF" face="宋体" size="5"><span style="background-color: #000080">邮件已成功发出!</span></font></b>"
' session("sended")="Y"
Else
if x=7 or x=5 then
Response.Write "<br/><br/><p align="center"><b><font color="#00FFFF" face="宋体" size="5"><span style="background-color: #000080">发邮件发生错误(" + cstr(x)+ ").发件人地址错误</span></font></b>"
1<br/><br/><input onclick="history.go(-1)" type="button" value="返回"/>
Response.End
else
Response.Write "<br/><br/><p align="center"><b><font color="#00FFFF" face="宋体" size="5"><span style="background-color: #000080">发邮件发生错误: " + cstr(x)+ "</span></font></b>"
1<br/><br/><input id="button1" name="button1" onclick="history.go(-1)" type="button" value="返回"/>
Response.End
end if
End If
Set SMTP = Nothing
1
2<p align="center"> <a href="javascript:window.close();">
3<font face="宋体" size="5"><b><span style="background-color: #FFFF00">返回</span></b></font></a></p>
4</p></p></font></p></body>
5</html>