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

时间:2011-03-10 19:31:21

标签: email asp-classic cdo.message

我正在使用asp创建一个应该向多个客户发送电子邮件的网页。有人建议我使用CDO电子邮件功能。这是经典asp网页的最佳解决方案吗?或者更好的是添加asp.net和ajax来处理电子邮件这类事情。

3 个答案:

答案 0 :(得分:3)

CDO将是明显的路线。在.Net Framework的某些版本中,ASP.Net只会使用CDO的包装器。

我不知道Ajax适用于这个主题。

粗俗和粗鲁(更好地引用global.asa中的库以获取类型信息并避免长字段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 
%>

答案 1 :(得分:1)

您是否要将Ajax添加到ClassicASP?我会说你在找麻烦。如果可能的话,我会鼓励客户转向.net技术。从长远来看,他们将感恩。

就CDO对象而言,请试用此链接How do I send e-mail with CDO?

答案 2 :(得分:1)

在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

%>