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")
myMail.Send
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 ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailout.mysite.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update

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?
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 MontySenior Web Developer / CEO of ExchangeTree.org Commented:
in IIS, under the Properties of SMTP, do you have the mail server set?
0
romsomIT DeveloperAuthor Commented:
Yes, I set the correct mail server.
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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).
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your server"
    Flds.update
        
    Set objMessage.Configuration = objConfig
    objMessage.To = toList
    objMessage.BCC = bccList
    objMessage.From = msgFrom
    objMessage.Subject = subject
    objMessage.HTMLBody = body
    objMessage.fields.update
    objMessage.Send

    set objMessage = nothing
    set objConfig = nothing
end sub

Open in new window

0
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.
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
were you able to try the app pool change?
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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).

https://msdn.microsoft.com/en-us/library/ms526318%28v=exchg.10%29.aspx

i think you'll be fine leaving the code in
0

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.
http://schemas.microsoft.com/cdo/configuration/sendusing
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!
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.