简体   繁体   中英

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.

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 = "from@me.com" 
        .To = "to@me.com" 
        .Subject = "Sample CDO Message" 
        .TextBody = "This is a test for CDO.message" 
        .Send 
    End With 

    Set cdoMessage = Nothing 
    Set cdoConfig = Nothing 
%>

It works this way on ASP Classic using CDO on GoDaddy hosting :

<%
Set ObjSendMail = CreateObject("CDO.Message")

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="relay-hosting.secureserver.net"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
ObjSendMail.Configuration.Fields.Update


'ObjSendMail.AddAttachment mPath, "Logo.gif"
'ObjSendMail.AddAttachment ArrwPath, "red_arrw.gif"

ObjSendMail.Subject = strSub
ObjSendMail.To = strTo
ObjSendMail.From = strFrom
ObjSendMail.Bcc = strBcc
ObjSendMail.Cc = strCc
ObjSendMail.HTMLBody = strMsg

ObjSendMail.Send
        Set ObjSendMail = Nothing

%>

Are you wanting to add Ajax to ClassicASP? I would say you are asking for trouble. If at all possible, I would encourage the customer to move to .net technology. They will be thankful in the long run.

As far as CDO objects, try out this link How do I send e-mail with CDO?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM