2009-08-05 49 views
2

我的ASP,傳統的ASP應用程序在Windows 2008 Server上給我一個服務器錯誤。它在Windows 2003服務器上正常工作。該錯誤是500內部服務器錯誤。 CDO不適用於Windows 2008嗎?如何在Windows 2008服務器上從ASP應用程序發送電子郵件

編輯 錯誤是:傳輸失敗連接到服務器。

這裏是我的郵件功能:

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 
+0

從ASP應用程序Windows 2008服務器發送電子郵件有哪些選項? – Picflight 2009-08-06 00:25:10

回答

5

看來,CDO/MAPI庫默認情況下,Windows 2008中未安裝:

你可以download them from Microsoft

參考from this blogpost

如果你想編寫客戶端應用程序 到 使用MAPI或CDO(例如,網絡 服務器)和你不想安裝 的計算機上運行(或無法安裝)Outlook 客戶端或Exchange管理 工具,則需要安裝 MAPI/CDO庫。

+0

鏈接被破壞,所以這裏是新的:http://www.microsoft.com/en-us/download/details.aspx?id=1004 – stare 2013-12-09 21:38:25

+0

從來沒有這樣做,感謝您的建議! – stare 2013-12-11 17:15:08

相關問題