经典ASP中的CDOSYS电子邮件架构

时间:2014-07-18 12:36:05

标签: email asp-classic windows-server-2012-r2 cdonts

我正在编写代码以通过CDOSYS发送电子邮件。我必须在同一个asp页面的不同地方写电子邮件发送代码。我是否需要对每个代码使用以下架构链接?如果我在变量中声明它并尝试使用它不起作用并给出错误...我的经典ASP网站部署在Windows Server 2012R2上 (http://schemas.microsoft.com/cdo/configuration

mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailsite
mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = websiteemail
mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") =globalpassword

1 个答案:

答案 0 :(得分:0)

您可以避免重复代码,就像避免在其他任何地方重复代码一样:在子例程中重复执行需要执行的操作。

Sub EmailConfig(mailobj)
    mailobj.Configuration.Fields.Item("http://blahblahblah") = 1
    'etc.
End Sub