简体   繁体   English

CDO电子邮件是使用经典ASP发送电子邮件的最佳方式吗?

[英]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. 我正在使用asp创建一个应该将电子邮件发送给多个客户端的网页。 It was suggested that I use CDO email functionality. 建议我使用CDO电子邮件功能。 Is this the best solution for a classic asp webpage? 这是经典ASP网页的最佳解决方案吗? Or would it be better to add asp.net and ajax for handling email this type of thing. 或者添加asp.net和ajax来处理这种类型的电子邮件会更好。

CDO would be the obvious route. CDO将是显而易见的途径。 In some versions of the .Net Framework ASP.Net would just be using a wrapper around CDO anyway. 在.Net Framework的某些版本中,无论如何,ASP.Net只会在CDO周围使用包装器。

I have no clue where Ajax fits into this topic. 我不知道Ajax适合该主题的地方。

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: 粗鲁(最好引用global.asa中的库以获取类型信息并避免使用冗长的Field ID字符串和幻数)示例复制/粘贴且未经我验证:

<% 
    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 : 它在GoDaddy托管上使用CDO在ASP Classic上以这种方式工作:

<%
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? 您是否要将Ajax添加到ClassicASP? I would say you are asking for trouble. 我会说你在找麻烦。 If at all possible, I would encourage the customer to move to .net technology. 如果有可能,我鼓励客户转向.net技术。 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? 至于CDO对象,请尝试此链接如何使用CDO发送电子邮件?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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