Neil Gould said:
(Mostly snipped for brevity)
I guess I was being over-inclusive. ;-)
Sure. This is all that is needed to send mail from our particular ISP:
Set objMail= Server.CreateObject("CDO.Message")
With objMail
.From = Session.Contents.Item("From")
.To = MailData("PrimEmail")
.Subject = Session.Contents.Item("Subj")
.TextBody = Session.Contents.Item("Msg")
IF Trim(Session.Contents.Item("Attach")) > "" THEN
.AddAttachment(Session.Contents.Item("Attach"))
END IF
.Send
End With
Set objMail = Nothing
So... my question is about the lines in your example:
What is gained by adding them, or risked by omitting them?
Your ISP has used server extensions to specify default values for
CDO.Configuration settings. Hence the default configuration object that the
CDO.Message object is given on creation has the above settings already so
your code need not worry about them.
I included them because on a vanillia IIS server these settings are not
defaulted.
Gains you can achieve by using them is control of extactly how an email gets
sent. Bear in mind that many IIS are managed by the site owners rather than
an ISP and therefor greater control is available. I have clients who want
to be able to dispatch emails via pickup folder. Not something you
typically do on an ISP hosted site.
The risks are that the ISP may not support the changes you make to the
configuration, for example, the may insist that all SMTP traffic go out via
their own SMTP server.
My advice is if the ISP has configured the mail settings for the site for
you, then use those, it keeps your code simple and is more likely to work.
On the downside if you choose to move your code to another ISP you may find
you need to add more code to get it work. If you use CDO from more than
one page consider wrapping up the CDO code in class and place it in an
include file.