[英]How to send email from ASP application on Windows 2008 Server
My ASP, classic ASP application is giving me a sever error on a Windows 2008 Server. 我的ASP,经典的ASP应用程序在Windows 2008 Server上给我一个严重错误。 It works fine on Windows 2003 server. 它在Windows 2003 Server上运行良好。 The error is a 500 internal server error. 该错误是500个内部服务器错误。 Does CDO not work on Windows 2008? CDO在Windows 2008上不起作用吗?
EDIT THe error is: The transport failed to connect to the server. 编辑错误是:传输无法连接到服务器。
Here is my mail function: 这是我的邮件功能:
function SendMail(mailFrom, mailTo, mailSubject, mailBody, bHtml)
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"
Const smtpServer = "localhost"
Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields
' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = smtpServer
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "username"
.Item(cdoSendPassword) = "password"
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = mailTo
.From = mailFrom
.Subject = mailSubject
if bHtml then
.HtmlBody = mailBody
else
.TextBody = mailBody
end if
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
end function
It appears that the CDO/MAPI libraries aren't installed by default in Windows 2008: 在Windows 2008中,默认情况下似乎未安装CDO / MAPI库:
You can download them from Microsoft . 您可以从Microsoft下载它们 。
Referenced from this blogpost : 从此博客文章引用:
If you want to write client applications to run on computers that use MAPI or CDO (for example, web servers) and you don't want to install (or can't install) either the Outlook client or the Exchange management tools, then you need to install the MAPI/CDO libraries. 如果要编写客户端应用程序以使其在使用MAPI或CDO的计算机(例如Web服务器)上运行,并且不想安装(或不能安装)Outlook客户端或Exchange管理工具,则可以需要安装MAPI / CDO库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.