Solved

Send mail with classic asp on IIS7 (CDO.Message)

Posted on 2010-08-25
14
12,206 Views
Last Modified: 2012-05-10
I have moved a classic asp (3.0) site from Windows 2003 to Windows 2008 server. Now, the mailforms don't work. I have installed SMTP server on the Windows 2008 server.

After hours of research and testing I have tried "everything". But still no luck. The webserver just give me this Errormessage: "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed."

In IIS I have changed the ASP Debugging Properties: Send Error To Browser = True. I have also changed "Show friendy Error Messages to False in Internet Explorer.

The mail script I use is attached. Does anyone have a clue why it don't work on my Windows 2008 Server?
Set cdoMail = CreateObject("CDO.Message")
Set cdoConfig = CreateObject("CDO.Configuration")
Set Flds = cdoConfig.Fields

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

With cdoMessage
Set .Configuration = cdoConfig
.To = "me@mydomain.com"
.From = "you@yourdomain.com"
.Subject = "test"
.TextBody = "Here is the message"
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
Set Flds = Nothing

Open in new window

0
Comment
Question by:webressurs
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33526164
CDO is for windows 2000. It will not work by default in windows 2003 based system.
kindly check whether it is installed or not
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33526191
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 167 total points
ID: 33526916
Actually CDO, as you are using it, should work.  It was CDONTS that was for Windows 2000 and earlier and is now deprecated.Are you sure SMTP works?  Is it set up on this same machine or another?  Can you test it to make sure that isn't the problem.  The code looks good.The other possibility is it needs authentication or requires some parameter you are leaving out.  If it is working and was set up by another then can they provide you with a sample of working code or details for the connection and use?bol
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 33526938
Also, make sure you do not have an "On Error Resume Next" line in your code.  I also suggest you add a block like the following below the .Send line (outside the With block).bol
If Err <> 0 then
	Response.Write "There was an error: " & Err.Description
End if

Open in new window

0
 
LVL 1

Author Comment

by:webressurs
ID: 33528742
Hi!

This is a new server (just installed now), in the Server Management SMTP is displayed as installed (I use the local SMTP server). Is there any way to check if the SMTP really works as it should?

The server is behind an external firewall, should this firewall open port 25?
0
 
LVL 1

Author Comment

by:webressurs
ID: 33528790
b0lsc0tt: When running the On Error Resume Next I get this error message:

There was an error: Object required

Does that give any clue?
0
 
LVL 10

Assisted Solution

by:Jini Jose
Jini Jose earned 167 total points
ID: 33528938
i think the server is not installed with cdosys
0
 
LVL 1

Author Comment

by:webressurs
ID: 33529202
How do I install cdosys? Isn't that installed by default?
0
 
LVL 14

Assisted Solution

by:wolfman007
wolfman007 earned 166 total points
ID: 33530052
Is your new Windows Server 2008 32 bit or 64 bit?

If it 64 bit then you are going to have to do some configuring to get cdosys working.

You will need to create a special App Pool to run your application in as a 32 bit application, rather that as a 64 bit application.

You will then need to download and register cdosys.dll on your Windows Server 2008.

See the following website for some instructions

CDOSYS 64-bit Windows Server 2008 tutorial
http://www.fordwebs.com/cdosys.cfm
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33530428
did u checked the two links that i posted earlier ?
0
 
LVL 1

Author Comment

by:webressurs
ID: 33532636
I have successfully registered cdosys.dll using regedt32. After further research I have also changes my code, please see attached.

The good thing is that I don't get any errormessage longer, the bad thing is that I don't recieve any email! I guess the email is not sent...

Any clue?
        Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing" 
        Const cdoSendUsingPort=2 
        Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver" 
        Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport" 
        Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" 
         
        Dim objConfig  ' As CDO.Configuration 
        Dim objMessage ' As CDO.Message 
        Dim Fields     ' As ADODB.Fields 

        Set objConfig = Server.CreateObject("CDO.Configuration") 
        Set Fields = objConfig.Fields 
         
        ' Set config fields we care about 
        With Fields 
                .Item(cdoSendUsingMethod)       = cdoSendUsingPort 
                .Item(cdoSMTPServer)            = "localhost" 
                .Item(cdoSMTPServerPort)        = 25 
                .Item(cdoSMTPConnectionTimeout) = 10 
                .Update 
        End With 
         
        Set objMessage = Server.CreateObject("CDO.Message") 
        Set objMessage.Configuration = objConfig 
         
        With objMessage 
                .To       = "my@mail.com"
                .From     = "my@mail.com" 
                .Subject  = "test"
                .HTMLBody = "content" 
                .Send 
        End With 
         
        Set Fields = Nothing 
        Set objMessage = Nothing 
        Set objConfig = Nothing 

Open in new window

0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 33537483
Try the steps at the URL below to test if SMTP is working.  You don't need to try them all but just pick which will work best.  Let us know the results.  Thanks for the update but we should confirm smtp works before trying the next stuff.

http://www.petri.co.il/test_smtp_service.htm

bol
0
 
LVL 1

Author Comment

by:webressurs
ID: 33538960
Hello!
I got it to work nok. Actually it works with this simple code:

set objMail = server.CreateObject("CDO.Message")
objMail.from = "me@mail.com"
objMail.to = "you@mail.com"
objMail.subject = "subject"
objMail.HTMLBody = "Text here"
objMail.send
set objMail = nothing

I reinstalled the cdosys.dll, then it worked:
Uninstall: regsvr32 -u c:\windows\system32\cdosys.dll
Install: regsvr32 c:\windows\system32\cdosys.dll
0
 
LVL 1

Author Closing Comment

by:webressurs
ID: 33538967
Thanks for all help :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
lock down downloads folder 8 75
html Uncheck Checkbox 2 25
What are the basic system requirements for SQL ALWAYS ON? 1 28
Robocopy parameters. 6 17
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question