Search code examples
emailasp-classiccdo.message

Is CDO Email the best way to send email using classic asp?


I am using asp to create a webpage that is supposed to send email to several clients. It was suggested that I use CDO email functionality. Is this the best solution for a classic asp webpage? Or would it be better to add asp.net and ajax for handling email this type of thing.


Solution

  • CDO would be the obvious route. In some versions of the .Net Framework ASP.Net would just be using a wrapper around CDO anyway.

    I have no clue where Ajax fits into this topic.

    Crude and rude (better to reference the library in global.asa to get type info and avoid the long Field ID strings and magic numbers) example copy/pasted and not verified by me:

    <% 
        sch = "http://schemas.microsoft.com/cdo/configuration/" 
    
        Set cdoConfig = CreateObject("CDO.Configuration") 
    
        With cdoConfig.Fields 
            .Item(sch & "sendusing") = 2 ' cdoSendUsingPort 
            .Item(sch & "smtpserver") = "<enter_mail.server_here>" 
            .Update 
        End With 
    
        Set cdoMessage = CreateObject("CDO.Message") 
    
        With cdoMessage 
            Set .Configuration = cdoConfig 
            .From = "[email protected]" 
            .To = "[email protected]" 
            .Subject = "Sample CDO Message" 
            .TextBody = "This is a test for CDO.message" 
            .Send 
        End With 
    
        Set cdoMessage = Nothing 
        Set cdoConfig = Nothing 
    %>