开发者

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 sugge开发者_如何转开发sted 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 
%>


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?


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

%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜