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

_青云_ PM  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
...全文
202 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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
怎么没人回复啊?看来今天我这分又送不出去了!
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-12-03 12:27
社区公告
暂无公告