http://www.szasp.cn/HTML/30/31/2007/14670.html
<%
function send_mail(s_email,s_email2,s_topic,s_body)
'参数说明
's_email: 主要邮件地址
's_email2: 备用邮件地址
's_topic: 邮件主题
's_body: 邮件内容
dim eAccount,vTmp,iConf,Flds,oMail
eAccount = "test@smtp.126.com" '这里是你的邮件服务器地址和登陆名,我用的是126的邮箱做的测试
vTmp = Split(eAccount, "@", -1, vbTextCompare)
Set iConf = server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort这里是发送邮件端口
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = vTmp(1)
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 '这里是SMTP服务器端口
Flds("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") = eAccount
Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = eAccount
Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = vTmp(0)
Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxx" '我的126邮箱密码
Flds.Update
set oMail = server.CreateObject("CDO.Message")
oMail.To = s_email
If s_email2<>"" Then
oMail.CC = s_email2
End If
oMail.Subject = s_topic
oMail.HTMLBody = s_body
oMail.From = "test@126.com" '这里必须和上面的登陆名一致
Set oMail.Configuration = iConf
oMail.MimeFormatted = True
oMail.AutoGenerateTextBody = True
oMail.Fields.Update
oMail.HTMLBodyPart.Charset = "gb2312"
oMail.Send
Set oMail = Nothing
Set Flds = Nothing
Set iConf = Nothing
send_mail=true
if err then
err.clear
send_mail=false
end if
end function
If send_mail(test@163.com","test2@163.com","邮件主题","邮件内容")=true Then
'发送成功
Else
'发送失败
End If
%>
另一篇
How to send HTML formatted mail using CDO for Windows 2000 and a remote SMTP service
http://support.microsoft.com/kb/286431
<script type="text/javascript">function loadTOCNode(){}</script>Article ID | : | 286431 |
Last Review | : | August 25, 2005 |
Revision | : | 3.1 |
SUMMARY
<script type="text/javascript">loadTOCNode(1, 'summary');</script>MORE INFORMATION
<script type="text/javascript">loadTOCNode(1, 'moreinformation');</script>1. |
|
2. | Edit the sections of the code that are marked "ToDo". |
3. | Save the file, and then double-click it. The code creates an HTML-formatted message and sends it using the remote computer's SMTP service. |