Click to See Complete Forum and Search --> : ASP & VBScript Problem...


kwilliams
10-06-2004, 10:08 AM
I have an ASP page that uses VBScript to send mail using CDONTS (see code below), and everything was working fine. But we recently moved our website to our new web server, that runs IIS 6.0 with ASP.NET. My questions is, shouldn't this page still run fine on this new server? I know that VBScript doesn't work in ASP.NET pages, but that shouldn't change this page since it uses ASP should it? Have any of the referenced MS schemas changed recently for CDONTS? I've included the referenced code below. Any advice would be greatly appreciated. Thanks.

<%@LANGUAGE="JAVASCRIPT"%>
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
'***EMAIL JOB BEGINS***
Response.Buffer = True
Const cdoSendUsingPickup = 1
Const strPickup = "c:\Program Files\Exchsrvr\mailroot\vsi 1\Pickup"

Set objSendMail = CreateObject("CDO.Message")
Set iConf = objSendMail.Configuration

With iConf.Fields
.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
.item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = strPickup
.Update
End With

With objSendMail
.To = "MYSELF@MYSITE.COM"
' .CC = "MYSELF@MYSITE.COM"
.From = Session("Email")
.Subject = "SUBJECT"
.HTMLBody = "<p>EMAIL BODY</p>"
.Send
End With
'***EMAIL JOB ENDS***
</SCRIPT>
<%
//Response.Write(Session("Email"));
Response.Redirect("HTTP://WWW.MYSITE.COM/THANKYOU.ASP");
%>

schizo
10-06-2004, 10:10 AM
Is your new web server Windows Server 2003? If so, you need to use the CDO mailer.

kwilliams
10-06-2004, 10:11 AM
Yes it is...sorry that I didn't include that info. What's the "CDO mailer", and how should I go about using it?

schizo
10-06-2004, 10:16 AM
Here's an example of a CDO mailer. Win Server 2k3 no longer supports CDONTS specifically.


'CDOSYS
Set email = Server.CreateObject("CDO.Message")
email.From = "sender@domain.com"
email.To = "recipient@domain.com"
email.Subject = "Some title"
email.HTMLBody = "Body text"
email.Send
Set email = Nothing


Let me know if you have any more problems.

kwilliams
10-06-2004, 10:18 AM
Well that's good to know. I wish that my NA had let me know of that change before he installed the new server...he must not have known. Thanks for your SPEEDY response...it's GREATLY appreciated!!!

schizo
10-06-2004, 10:28 AM
Actually, it looked like you had been using CDO anyways...

Set objSendMail = CreateObject("CDO.Message")


An example CDONTS object would have looked like this:

Set objSendMail = CreateObject("CDONTS.NewMail")


I'd try scaling down your code a bit to something like I posted. Send a few test emails and see if that works, then go from there. If the test emails aren't sent, something may not be configured properly with your server's SMTP.

kwilliams
10-06-2004, 10:32 AM
Hi schizo,

I was just figuring that out...duh. Anyway, I did try scaling down the code a lot, but that didn't make it work. Unfortunately our NA is out for the week, so I'll likely have to wait until next week for a solution concerning our SMTP server. But thanks again for all of your help.

kwilliams
10-06-2004, 10:59 AM
A solution has been found, but it involved changing the code a bit for the new Win2k3 server. Here's the new working script:
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
Response.Buffer = True
Set objSendMail= Server.CreateObject("CDO.Message")
With objSendMail
.From = Session("Email")
.To = "MYSELF@MYSITE.COM"
.Subject = "SUBJECT TEXT"
.HTMLBody = "BODY TEXT"
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "EMAILSERVERNAME"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
.Send
End With
</SCRIPT>

Again, thanks for the tremendous amount of advice on this issue. It's really nice to know that there's a real support system out there for us Web Developers. Have a great week everyone:)

schizo
10-06-2004, 11:23 AM
Yeah that is a workaround to use an external SMTP server. If your SMTP was configured properly on your own server, a CDO.Configuration would not be necessary.

Glad you got it working.