急!!!在线等!如何用CDO.Message在windows server 2003下发邮件
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
问题点数:0、回复次数:8Top
1 楼yqh1314(‰兆雪伊人倍思逢☆)回复于 2004-12-03 12:32:21 得分 0
先占个一楼 回头帮你好好解决!Top
2 楼yangyp01(化冰)回复于 2004-12-03 12:46:10 得分 0
yqh1314(‰爱你不是三两天☆)
还是现在帮我解决吧,大不子我多给点分就是了,急啊!谢谢了!
Top
3 楼yangyp01(化冰)回复于 2004-12-03 13:03:37 得分 0
怎么没人回复啊?看来今天我这分又送不出去了!Top
4 楼tjficcbw(津津)回复于 2004-12-03 13:11:56 得分 0
<%
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>
Top
5 楼yangyp01(化冰)回复于 2004-12-03 13:34:53 得分 0
我是在server 2003下发送,里面没有CDONTS.dll只有CDOSYS.dllTop
6 楼yangyp01(化冰)回复于 2004-12-06 15:06:23 得分 0
还没有人回复我,唉,这问题就这么难吗?Top
7 楼yangyp01(化冰)回复于 2004-12-09 16:17:11 得分 0
自己顶一下Top
8 楼cmslovehxh(关中刀客)回复于 2004-12-30 20:17:52 得分 0
<%
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
%>
Top
相关问题
- windows xp sp2系统下,发现金碟k3系统的web界面没法登录?
- windows 200 server serial no
- ASP.NET下发送EMAIL问题
- linux下发布web应用
- 请问:硬盘windows目录下发现一个MEMORY.DMP的文件,足有523MB,不知道是什么东西? 能不能删除?
- 急!Microsoft CDO for Exchange 2000 Server Library这个组件在哪?
- 急!Microsoft CDO for Exchange 2000 Server Library这个组件在哪?
- 关于windows 2000 server
- windows 2000 server 服務
- WINDOWS 2000 SERVER 错误




