0
votes

I am writing code to send email via CDOSYS. I have to write email sending code in different places in same asp page. Do i need to use following schema link with everycode? If i declare it in variable and try to use it doesn't work and give error... My classic ASP website is deployed on 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

1 Answers

0
votes

You can avoid duplicating code the same way you would avoid duplicating code anywhere else: put the stuff you need to do repeatedly in a subroutine.

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