急!!!在线等!如何用CDO.Message在windows server 2003下发邮件

_青云_ 2004-12-03 12:27:39
function mail(fromAddr,toAddr,mailSubject,mailhtml,mailurl)
Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort=2
Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic=1
Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields

Set objConfig = Server.CreateObject("CDO.Configuration") '就在这一行出现Server 对象 错误 'ASP 0177 : 800401f3' Server.CreateObject 失败
Set Fields = objConfig.Fields

With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "stmp.163.com" 'Your SMTP Server
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "admin@163.com" 'User name at SMTP Server
.Item(cdoSendPassword) = "123456" 'Password at SMTP Server
.Update
End With


Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig

With objMessage
.To = toAddr '改成接收者的邮件地址
.From = fromAddr '改成发送人的邮件地址
.Subject = mailSubject '标题
.TextBody = "这是一封HTML格式的邮件,请切换到HTML方式查看该邮件。"
.HtmlBody = mailhtml
if mailurl<>"" then
.CreateMHTMLBody mailurl,0
end if
.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
end function
...全文
255 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cmslovehxh 2004-12-30
  • 打赏
  • 举报
回复
<%
Const cdoBasic = 1 'Use basic (clear-text) authentication.
Const cdoSendUsingPort = 2
'cdosys related
Dim iMsg
Dim iConf
Dim Flds
'mail related
Dim strMsg
Dim strTo
Dim strCC
Dim strFrom
Dim strSubject
Dim strTextBody


'==================begin your configuration=============================
'you must have a username and pass word or you will not be able to send
'
Dim sendusername : sendusername = "user@userdomain.com"
Dim userpassword : userpassword = "yourpassword"
Dim smtpserver : smtpserver = "yoursmtpserver"
'end your configuration

'===================begin set your info here============================
'set your TO, CC, From, Subject and body here
'
strTo = "touser@somedomain.com"
strCC = "anotheruser@somedomain.com"
strFrom = "fromuser@somedomain.com"
strSubject = "Insert here your subject text"
strTextBody = "Insert here your plain body text"
'end set your info here


'Create message and configuration objects
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
'Apply settings to the configuration object
With Flds
' Specify the authentication mechanism to basic (clear-text) authentication.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
' The username for authenticating to an SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sendusername
' The password used to authenticate to an SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = userpassword
' Port
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'Specify mail server
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
'Specify the timeout in seconds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
' The port on which the SMTP service specified by the smtpserver field is listening for connections (typically 25)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
'.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Update
End With

'Apply the settings to the message object and send it
With iMsg
Set .Configuration = iConf
.To = strTo
.From = strFrom
If strCC <> "" Then
.CC = strCC
End If
.Subject = strSubject
.TextBody = strTextBody
'Send message
.Send
End With
' cleanup mail objects
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
%>
_青云_ 2004-12-09
  • 打赏
  • 举报
回复
自己顶一下
_青云_ 2004-12-06
  • 打赏
  • 举报
回复
还没有人回复我,唉,这问题就这么难吗?
_青云_ 2004-12-03
  • 打赏
  • 举报
回复
yqh1314(‰爱你不是三两天☆)
还是现在帮我解决吧,大不子我多给点分就是了,急啊!谢谢了!
yqh1314 2004-12-03
  • 打赏
  • 举报
回复
先占个一楼 回头帮你好好解决!
_青云_ 2004-12-03
  • 打赏
  • 举报
回复
我是在server 2003下发送,里面没有CDONTS.dll只有CDOSYS.dll
tjficcbw 2004-12-03
  • 打赏
  • 举报
回复
<%
if Cint(request("send"))=1 then
on error resume next
set mymail=server.CreateObject ("CDONTS.Newmail")
mymail.mailformat=0
mymail.bodyformat=0
mymail.from =request("from")
mymail.to =request("to")
mymail.BCC =request("bbc")
mymail.subject =request("subject")
mymail.body =request("body")
mymail.send
if err.number<>0 then
response.write err.description
response.end
end if
set mymail=Nothing
response.write "邮件已成功发送到"+request("to")
response.end
end if
%>
<html>
<body>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#6699FF">
<form method="post">
<tr bgcolor="#E7E7CB">
<td width="20%" height="26">发件人:</td>
<td width="80%"><input name="from" type="text"></td>
</tr>
<tr bgcolor="#E7E7CB">
<td height="25">收件人:</td>
<td><input name="to" type="text"></td>
</tr>
<tr bgcolor="#E7E7CB">
<td height="23">密送地址:</td>
<td><input name="bbc" type="text"></td>
</tr>
<tr bgcolor="#E7E7CB">
<td height="24">邮件标题:</td>
<td><input name="subject" type="text" size="50"></td>
</tr>
<tr bgcolor="#E7E7CB">
<td height="27">邮件内容:</td>
<td><textarea name="body" cols="60" rows="10"></textarea></td>
</tr>
<tr bgcolor="#E7E7CB">
<td height="28"> </td>
<td>
<input type="hidden" value="1" name="send">
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置"></td>
</tr>
</form>
</table>
</body>
</html>
_青云_ 2004-12-03
  • 打赏
  • 举报
回复
怎么没人回复啊?看来今天我这分又送不出去了!

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧