How to send email from ASP application on Windows 2008 Server

13,871

It appears that the CDO/MAPI libraries aren't installed by default in Windows 2008:

You can download them from 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.

Share:
13,871
Picflight
Author by

Picflight

Updated on June 04, 2022

Comments

  • Picflight
    Picflight almost 2 years

    My ASP, classic ASP application is giving me a sever error on a Windows 2008 Server. It works fine on Windows 2003 server. The error is a 500 internal server error. Does CDO not work on 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
    
    • Picflight
      Picflight over 14 years
      What are options are there on send email from ASP application Windows 2008 server?
  • John
    John over 10 years
    Link is broken so here is the new one: microsoft.com/en-us/download/details.aspx?id=1004