CDO Email Configuration in IIS 8

Hi Experts,
I moved my website to a new server and I'm trying to send email using the code below:

Set myMail=CreateObject("CDO.Message")
myMail.Subject= Request.form("Subject")
myMail.From= Request.Form("YourEmail")
myMail.To= Request.Form("MyEmail")
myMail.HTMLBody = Request.form("Comments")
set myMail=nothing

I get the following error message:

CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.

To troubleshoot the problem I added the following lines, and I could send the email successfully:

myMail.Configuration.Fields.Item ("") = 2
myMail.Configuration.Fields.Item ("") = ""
myMail.Configuration.Fields.Item ("") = 25

I would like to know if there is a way to configure the email settings on the server, instead of having to add these microsoft links to my code. When I log in to the server I don't see an option to configure SendUsing.
In Authentication Settings I clicked "Not Required" and I entered Port 25.

I would appreciate your help
romsomIT DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
in IIS, under the Properties of SMTP, do you have the mail server set?
romsomIT DeveloperAuthor Commented:
Yes, I set the correct mail server.
Big MontyWeb Ninja at largeCommented:
are you running under the default app pool? (DefaultAppPool)? if not, try switching over, as there may be a permissions issue to the IIS Metabase (the database where IIS keeps all of its settings).
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Big MontyWeb Ninja at largeCommented:
i don't know if there's any way to send emails remotely without specifying those fields, as I believe CDO will default to using localhost if no server is specified in the code.

is there any particular reason why you don't want that code in there? you could put the code in it's only file, in a function, and then include that file wherever you need to send mail, calling the function to create (and send if you like) your email:

sub sendEmail( msgFrom, toList, bccList, subject, body )
    set objMessage = Server.Createobject("cdo.message")
    set objConfig = Server.Createobject("cdo.configuration")

    ' Setting the SMTP Server
    Set Flds = objConfig.Fields
    Flds.Item("") = 2
    Flds.Item("") = "your server"
    Set objMessage.Configuration = objConfig
    objMessage.To = toList
    objMessage.BCC = bccList
    objMessage.From = msgFrom
    objMessage.Subject = subject
    objMessage.HTMLBody = body

    set objMessage = nothing
    set objConfig = nothing
end sub

Open in new window

romsomIT DeveloperAuthor Commented:
The reason I don't want the microsoft links is that my site is on the intranet, and external links cannot be accessed. I'm afraid users won't be able to send the email, if they don't have access to internet on the work computers they are using.
Big MontyWeb Ninja at largeCommented:
were you able to try the app pool change?
Big MontyWeb Ninja at largeCommented:
another question, have you actually tried this in your intranet?

doing some more research, the references to the different schemas are actually namespaces, and not real url's (try going to one).

i think you'll be fine leaving the code in

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
romsomIT DeveloperAuthor Commented:
I tried everything on the server with no success. Users confirmed that they are able to send emails from the pages where I have the microsoft links in the CDO message. It's interesting that when I click the links, e.g.
nothing shows up. They might not be real URLs, as you say. As long as my applications are working, I don't really mind using the code. It's just a pain to go through all my applications and add those three lines in each email form. I was trying to avoid that.
I wonder how come on the old server the pages were working, when I had the same smtp configuration. It might be the fault of IIS8...
Thank you very much for your help, and have a great day!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.