Generally, most of our web site applications are in PHP or Coldfusion, but some are in classic asp and sometimes generate errors or don’t send mail out correctly. After investigating these two issues, I had to try a few things to come up with a solution. At first, the form was getting an internal server error 500 from IIS, which is a scripting error. The error said something like, “could not create com object.” I looked at the line where it was generating an error and read…
“Set MyCDONTSMail = CreateObject(“CDONTS.NewMail”)”
I scoured through forums, blogs, and support pages to realize that the cdonts.dll (Acronym for Collaboration Data Object for NT Server Dynamic Link Library ) was not installed in the windows/system32 folder, after I extracted it to that location then ran the command regsvr32, which is the command line program to register dll files. Once I ran the command, I got an error “LoadLibrary(“condts.dll”) failed”, so I went back searching through the forums and realized that since our server is a 64 bit edition, 32 bit dlls don’t go in the %sysroot%\system32 folder, they go in the %sysroot%\SysWOW64 folder. How is it that logically 32 bit dlls go in the SysWOW64 folder and 64 bit dlls go in the system32 folder? I’m sure Microsoft has a good reason.
I extracted the file into that directory, changed the path in the command prompt to windows\SysWOW64 and ran the command “regsvr32 cdonts.dll” when I got an alert that it was a success. So, I went back to the web page, posted the form, and waited a few minutes for an email to come through. After a few more minutes, I tried a different email server and posted the form again to no avail. I went searching through Microsoft support pages and our forums and blogs to realize asp needs IIS to be running to the SMTP service. So, rather than start that server, I checked with our SMTP mail server Merak and used a different dll object to send mail.
Set Mail = Server.CreateObject( “IceWarpCOM.Mailer” )
Mail.RemoteHost = “localhost”
Mail.Helo = “localhost”
Mail.FromName = “ASP Form Mailer”
Mail.FromAddress = sEmail
Mail.MailFrom = Mail.FromAddress
Mail.AddRecipient “firstname.lastname@example.org”, “user’s name”
Mail.Subject = “contact form”
Mail.IsHTML = “False”
Mail.BodyText = MyBody