This topic is locked
[SOLVED]

 Sendmail Server 2008 iis7

4/29/2009 11:33:41 AM
ASPRunnerPro General questions
Stu author

My aplication which works perfectly on an old Windows 2000 server ii5 gives the following error on Server 2008 iis7
Technical information

Error number -2147221005

Error description 006~ASP 0177~Server.CreateObject Failed~800401f3

URL /customersupport/WebChat_add.asp

Solution Reinstall MDAC (Microsoft Data Access Components)

Using latest build of 6.0
I looked that your Sendmail code and note the detection of iis7 but your code path labels the following code as "XP/2000".
Will Sendmail work on Server 2008 with iis7. Can you advise how to make it work
Regards,
Stu

Stu author 4/29/2009

I checked the code you use in your Sendmail routine and its the same as recommended elsewhere on the web for CDO.
I thought I'd review how to setup e-mail in ASPRunner.
It seems to me that the Virtual SMTP server on iis is just like any other mail server. So, all it needs is the recipient and via DNS and it does its stuff.
If that is the case then how do the settings in ASPRunner Security have a bearing? I have found that if I don't set something then Sendmail never works even under older iis. Do I have to provide a downstream SMTP server ip in Security for Sendmail to work.
In iis7 SMTP you can set SMTP to use "localhost" or send SMTP to another Host.
Amongst all these combinations of settings which one's would I choose for iis7? That is what do I set in Security and what would I set in SMTP server in iis7.
Also, could it be something to do with CDO or even permission between the iis7 server and the external SMTP server that routes the e-mail?
Regards,
Stuart

My aplication which works perfectly on an old Windows 2000 server ii5 gives the following error on Server 2008 iis7

Technical information

Error number -2147221005

Error description 006~ASP 0177~Server.CreateObject Failed~800401f3

URL /customersupport/WebChat_add.asp

Solution Reinstall MDAC (Microsoft Data Access Components)

Using latest build of 6.0
I looked that your Sendmail code and note the detection of iis7 but your code path labels the following code as "XP/2000".
Will Sendmail work on Server 2008 with iis7. Can you advise how to make it work
Regards,
Stu

Stu author 4/29/2009

I found this item that seems to define what the problem is http://forums.iis.net/t/1144383.aspx
The answer says to use CDOSYS and not CDONTS and has a coding example
[codebox]<!--

METADATA

TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library"

-->

<%

Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields

.Item(cdoSendUsingMethod) = cdoSendUsingPort

.Item(cdoSMTPServer) = "192.161.1.10"

.Update

End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage

Set .Configuration = cdoConfig

.From = "myemail@sample.com"

.To = "youremail@sample.com"

.Subject = "Sample CDO Message"

.TextBody = "This is a test for CDO.message"

.Send

End With
Set cdoMessage = Nothing

Set cdoConfig = Nothing
Response.write "<HTML><head><title>A message has been sent.</title></head><body>A message has been sent.</body></HTML>"
%>
Replace the .To and .From email addresses as appropriate. Also chaneg the IP address of the SMTP server to yours.
If this doesn't work, tell us how you know it doesn't work. Just because the email didn't show up doesn't mean the code isn't working. Check the SMTP logs, check for firewalls, authentication requirements, spam filters and so on.
[/codebox]
Does this hold the answer and how would one implement this with a change to the Sendmail routine in commonfunctions.asp?
Regards,
Stu

I checked the code you use in your Sendmail routine and its the same as recommended elsewhere on the web for CDO.

I thought I'd review how to setup e-mail in ASPRunner.
It seems to me that the Virtual SMTP server on iis is just like any other mail server. So, all it needs is the recipient and via DNS and it does its stuff.
If that is the case then how do the settings in ASPRunner Security have a bearing? I have found that if I don't set something then Sendmail never works even under older iis. Do I have to provide a downstream SMTP server ip in Security for Sendmail to work.
In iis7 SMTP you can set SMTP to use "localhost" or send SMTP to another Host.
Amongst all these combinations of settings which one's would I choose for iis7? That is what do I set in Security and what would I set in SMTP server in iis7.
Also, could it be something to do with CDO or even permission between the iis7 server and the external SMTP server that routes the e-mail?
Regards,
Stuart

Admin 4/29/2009

Stu,
as a first step I recommend to make sure this sample works on your system. We'll proceed from there.

Stu author 4/30/2009

Sergey,
I'll try a few of the recommended approaches. One is to put CDONTS into iis7 and the other is to use CDOSYS.
Here is another article on using CDOSYS. http://www.w3schools.com/asp/asp_send_email.asp
I will feedback to everyone what solution I adopted .
Regards,
Stu

Stu,

as a first step I recommend to make sure this sample works on your system. We'll proceed from there.

Stu author 4/30/2009

Yipeee!!!!
I tried the sample code I found in one of those links and IT WORKS! Its just seamless.
Here is the code change to Sendmail in commonfunctions.asp. I commented out the CDO code and just added the CDOSYS code after the test for iis7
Best Regards,
Stu
[codebox]Sub sendmail(email, subject, message)
Dim i

if email="" or isnull(email) then

strMessage = "Email address is empty. Cannot send email."

Exit Sub

end if
'On Error Resume Next
Version = Request.ServerVariables("SERVERSOFTWARE")

If InStr(Version, "Microsoft-IIS") > 0 Then

i = InStr(Version, "/")

If i > 0 Then

IISVer = Trim(Mid(Version, i+1))

End If

End If
If IISVer <= "5.0" or IISVer = "7.0" Then

' Windows NT / 2000

'Set myMail = Server.CreateObject("CDONTS.NewMail")

'myMail.From = cfrom

'myMail.To = email
'myMail.Subject = subject

'myMail.Body = message

'myMail.Send

'Set myMail = Nothing
Set cdoMessage = CreateObject("CDO.Message")

Set cdoConfig = CreateObject("CDO.Configuration")
Set Flds = cdoConfig.Fields
With Flds

.Item("http://schemas.microsoft.com/cdo/configuration/sendusing"'>http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2 'cdoSendUsingPort

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver"'>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"'>http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25

.Update

End With
With cdoMessage

Set .Configuration = cdoConfig

.To = email

.From = cfrom

.Subject = subject

.TextBody = message

.Send

End With
Set cdoMessage = Nothing

Set cdoConfig = Nothing

Set Flds = Nothing
SendEmail = true
Else

' Windows XP / 2003

Set myMail=CreateObject("CDO.Message")

myMail.Subject = subject

myMail.From=cfrom

myMail.To=email

myMail.TextBody= message

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing"'>http://schemas.microsoft.com/cdo/configuration/sendusing";)=2

'Name or IP of remote SMTP server

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver"'>http://schemas.microsoft.com/cdo/configuration/smtpserver";)=csmtpserver

'Server port

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport"'>http://schemas.microsoft.com/cdo/configuration/smtpserverport";)=csmtpport

' SMTP username and passwords

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword";) = csmtppassword

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername";) = csmtpuser

if csmtpuser<>"" then


myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";) = 1

myMail.Configuration.Fields.Update

myMail.Send

Set myMail = Nothing

End If
if Err.Number<>0 then

strMessage = "Error happened sending email to " & email & "
" & Err.Source & "
" & Err.Number & "
" & Err.Description
Err.Clear

end if
End Sub[/codebox]

Sergey,

I'll try a few of the recommended approaches. One is to put CDONTS into iis7 and the other is to use CDOSYS.
Here is another article on using CDOSYS. http://www.w3schools.com/asp/asp_send_email.asp
I will feedback to everyone what solution I adopted .
Regards,
Stu

Admin 4/30/2009

Stu,
try to remove or IISVer = "7.0" part in existing sendmail function. ASPRunnerPro already uses CDO (CDOSYS) you just need to make sure correct part of code is executed.

Stu author 5/7/2009

I just wanted to add that I got it all working with the code I showed above. However, for some reason I can't explain it stopped working with an error "The transport failed to connect to the server.".
It seems like it is an issue with security on Server 2008 and to do with the SMTP Service which has so many combinations of settings under IIS 7 on Server 2008. You can deliver to "localhost" or an SMTP server on your network, or out in ISP land! What's more you can set SMTP for the Site, Default Web Site and Virtual Directories, seemingly all different.
I eventually solved my problem with these settings. For the purpose of illustration the IP address of my local SMTP server is 192.168.1.1 . In Security Settings in ASPRUNNER I set:-
SMTP Server to 192.168.1.1

SMTP Port to 25

No Username or Password
On iis7 the SMTP Server setting is set to deliver to an external SMTP server, being 192.168.1.1. That is at all levels of the Web Server hierarchy.
The thing that Finally made all this work is a change to the code I posted above:-
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = "192.168.1.1"
It WAS set to "localhost". After I changed it then it worked.
I am really not sure which settings are the most important. I have a feeling that the settings in the new code for Sendmail overide any setting in the Security settings of ASPRUNNER.
Could Sergey pls confirm if tat would be so. I surmise this to be true because it was teh code change that made it work.
Best Regards,
Stu

Stu,

try to remove or IISVer = "7.0" part in existing sendmail function. ASPRunnerPro already uses CDO (CDOSYS) you just need to make sure correct part of code is executed.

Stu author 5/7/2009

One other thing. It is possible to keep the Sendmail code as delivered by ASPRUNNER but then install CDONTS on Server 2008.
I followed this article http://www.jppinto.com/index.php/2009/03/i...ws-server-2008/
Note the example on how to set SMPTP for local relay isn't the same dialogue for Server 2008.
I did it succesfully and the page displayed a test message on screen that I setup as if the mail was going to be delivered - but no mail was delivered. It may be that in CDONTS the SMTP server name has to come from ASPRUNNER Security Settings. Not sure if I had them set correctly so you may wish to experiment.
I'd suggest trying this method first so it stays consistent with what ASPRUNNER delivers. If not then try the CDOSYS code I posted.
Regards,
Stu

Stu author 5/8/2009

UPDATE:-
Possible code error in my coding example
I think you should change [codebox]SendEmail = true[/codebox] to [codebox]Sendmail = true[/codebox]
Also, instead of commenting out the older code I suggest a 100% substitute with teh new code
Regards,
Stu

One other thing. It is possible to keep the Sendmail code as delivered by ASPRUNNER but then install CDONTS on Server 2008.

I followed this article http://www.jppinto.com/index.php/2009/03/i...ws-server-2008/
Note the example on how to set SMPTP for local relay isn't the same dialogue for Server 2008.
I did it succesfully and the page displayed a test message on screen that I setup as if the mail was going to be delivered - but no mail was delivered. It may be that in CDONTS the SMTP server name has to come from ASPRUNNER Security Settings. Not sure if I had them set correctly so you may wish to experiment.
I'd suggest trying this method first so it stays consistent with what ASPRUNNER delivers. If not then try the CDOSYS code I posted.
Regards,
Stu

Admin 5/8/2009

Stu,
I'm afraid I've lost the track a little bit. I'm glad you found a workaround that works in your environment.
I can also recommend to check ASPRunnerPro 6.1 that features improved runner_mail() function with HTML emailing capabilities, error handling and smarter logic. It tries to send an email via CDO first and if it doesn't work it switches to CDONTS.

Stu author 5/14/2009

Sergey,
Sorry for all my commentary. In fact that change to SendEMail=True resulted in an error and I hade to change it back.
When I initially got it working with the very first code for CDOSYS it was fine and then suddenly stopped working. I found that by simply deleting the older code let it work again. Then it stopped again and so I reloaded 766, added back the CDOSYS code and its working now. Hence my "Its working" - "It ain't working" switching.
I was really hoping to leave a trail for people with a similar problem so they had some resources and ideas.
I do have 6.1 but it was giving a few errors and a switch back to 6.0 766 was smooth so I stayed with it until my project was delivered. If you could just indicate a link to the very latest 6.1 I will try it again.
Using ASPRunner has enhanced my reputation for delivering web-enabled data functionality so I once again thank you for the product.
Regards,
Stu]

Stu,

I'm afraid I've lost the track a little bit. I'm glad you found a workaround that works in your environment.
I can also recommend to check ASPRunnerPro 6.1 that features improved runner_mail() function with HTML emailing capabilities, error handling and smarter logic. It tries to send an email via CDO first and if it doesn't work it switches to CDONTS.

Stu author 5/14/2009

Sergey,
I gave 6.1 Build 1379 a quick try and my project that works perfectly under 6.0 Build 766 immediately pulls an error on Login.
"Error Type:

Microsoft VBScript runtime (0x800A01C2)

Wrong number of arguments or invalid property assignment: 'AfterSuccessfulLogin'

/WebPortal6_0_WithEmail_V15-NewCosmetics/login.asp, line 78"
Line 78 and thereabouts is
[codebox] end if

if bValue(logged) then

doArrayAssignment Session,"UserID",pUsername

Session("AccessLevel") = ACCESS_LEVEL_USER

Session("GroupID") = ""

doArrayAssignment Session,"OwnerID",data("ID")

doArrayAssignment Session,"_dbo.CompanyAddressCodeValid_OwnerID",data("ID")

if bValue(asp_function_exists("AfterSuccessfulLogin")) then

'LINE 78 AfterSuccessfulLogin pUsername,pPassword,data

end if

if bValue(myurl) then

asp_header "Location: " & CSmartStr(myurl)

else

asp_header "Location: " & CSmartStr(defaulturl)

end if

response.end

else

if bValue(asp_function_exists("AfterUnsuccessfulLogin")) then

AfterUnsuccessfulLogin pUsername,pPassword

end if

message = "Invalid Login"

end if[/codebox]
Its being faced with the developer nightmare. "It works in the previous version, if I plough through and fix all errors for the new version then I might find something I have to re-code and I don't know how long until I deliver something stable again"
Unless you have a newer build that should make this type of problem go away then I have to stay one version behind.
Hope you understand
Best Regards,
Stu

Sergey,

Sorry for all my commentary. In fact that change to SendEMail=True resulted in an error and I hade to change it back.
When I initially got it working with the very first code for CDOSYS it was fine and then suddenly stopped working. I found that by simply deleting the older code let it work again. Then it stopped again and so I reloaded 766, added back the CDOSYS code and its working now. Hence my "Its working" - "It ain't working" switching.
I was really hoping to leave a trail for people with a similar problem so they had some resources and ideas.
I do have 6.1 but it was giving a few errors and a switch back to 6.0 766 was smooth so I stayed with it until my project was delivered. If you could just indicate a link to the very latest 6.1 I will try it again.
Using ASPRunner has enhanced my reputation for delivering web-enabled data functionality so I once again thank you for the product.
Regards,
Stu]

Admin 5/14/2009

Stu,
I recommend to get final version of ASPRunnerPro 6.1. If this issue is still there post your application to Demo Account (use 'Demo Account' button on the last screen in program). Then open a ticket at http://support.xlinesoft.com sending your Demo Account URL for investigation.
This seems to be something minor, like event parameters list has changed. It should be converted automatically to the new format.