ASP发送邮件问题!请高手解决!
[bc02] 调用过程页面:
Dim Action
Action = Request("Action")
Select Case Action
Case "OK"
Call UserEmail()
End Select
Sub UserEmail()
Call Admin.Send_Mail_Too()
End Sub
%>
<form id="form1" name="form1" method="post" action="">
<table width="550" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="191" height="30"><div align="right">用 户 名:</div></td>
<td width="359"><input type="text" name="U_Name" id="U_Name" /></td>
</tr>
<tr>
<td height="30"><div align="right">电子邮件:</div></td>
<td><input type="text" name="U_Email" id="U_Email" /></td>
</tr>
<tr>
<td height="30"><div align="right">邮件内容:</div></td>
<td><textarea name="U_Text" id="U_Text" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="提交" />
<input name="Action" type="hidden" id="Action" value="OK"></td>
</tr>
</table>
</form>
过程页:
sub Send_Mail(table)
On error resume next
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII" JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True
JMail.From = "yeyucg@ ' 发送者地址
JMail.FromName = "+++++" ' 发送者姓名
JMail.Subject = "++++++" ' 邮件主题
JMail.MailServerUserName = "yeyucg@ ' 身份验证的用户名
JMail.MailServerPassword = "***********' 身份验证的密码
JMail.Priority = 3 ' 设置优先级,范围从1到5,越大的优先级越高,3为普通
JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
JMail.AddRecipient(""&Request("U_Email")&"") ' 加入一个收件人【变量email:收件人地址】可以同一语句重复加入多个
' 加入附件【变量200593093643.html:附件文件的绝对地址,确保用户IUSR_机器名有访问的权限】
' 【参数设置是(True)否(False)为Inline方式】
'contentId = JMail.AddAttachment (Server.MapPath("jmail.asp"), True)
' 邮件主体(HTML(注意信件内链接附件的方式))
JMail.HTMLBody =table
' 邮件主体(文本部分)
JMail.Body = "邮件正文,邮件正文,邮件正文"
' 发送【调用格式:objJMail.Send([username:password@]SMTPServerAddress[:Port])】
JMail.Send("202.108.28.166")
' 关闭并清除对象
JMail.Close()
Set JMail = Nothing
if err.number<>0 then
response.write "<script>alert('Err!');history.go(-1);</script>"
else
response.write "<script>alert('发送邮件成功!');location.href='default.asp';</script>"
end if
End sub
'===============
'发送邮件的具体内容
'===============
public sub Send_Mail_Too()
dim table
table = "<table width=550 border=0 cellspacing=0 cellpadding=0 style='border-collapse:collapse; border:1px solid #333333; background:#ffffff; margin-top:10px;'>"
table = table & "<tr>"
table = table & "<td width=680 style='border:1px solid #333333; margin:0; padding:3px;'>"
table = table & "邮件<font style='color:#ff0000; font-weight:bold; font-size:14px;'>"&Request("U_Text")&"</font>请及时回复!"
table = table & "</td>"
table = table & "</tr>"
table = table & "</table>"
Call Send_Mail(table)
end sub
运行时老弹出 Err!