Like so many of you at the moment I am moving a legacy classic ASP application from a Windows 2003 server to Windows 2008. I have this mostly working but I am unable to send e-mail through it. This is because CDOSYS is not configured correctly. Despite about 4-5 hours' googling and running through API documentation and even searching through all files on the filesystem and the system registry I was unable to figure out where this is set.
The ASP.NET portion of the legacy application works fine. It is able to send e-mails to localhost without authentication which are then passed through to the mail server with authentication for sending to their destination.
I translated the VB6 calls from the source code into a Powershell script for convenience:
$config = new-object -com "CDO.Configuration";
$config.Load(1);
$smtp = new-object -com "CDO.Message";
$smtp.Configuration = $config;
$smtp.From = "[email protected]"
$smtp.To = "[email protected]"
$smtp.Subject = "test"
$smtp.TextBody = "Message";
$smtp.Send();
This script sends an e-mail correctly on my original server. On the new server it returns this error when calling $smtp.Send()
:
Exception calling "Send" with "0" argument(s): "The "SendUsing" configuration value is invalid.
The configuration between the two servers is quite different. Using the $config
reference from above, I executed $config.Fields | Format-List -Property Name,Value
on both servers.
Old server (where it works):
Name : http://schemas.microsoft.com/cdo/configuration/languagecode
Value : en-us
Name : http://schemas.microsoft.com/cdo/configuration/postusing
Value : 0
Name : http://schemas.microsoft.com/cdo/configuration/sendusing
Value : 1
Name : http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory
Value : D:\Inetpub\mailroot\Pickup
Name : http://schemas.microsoft.com/cdo/configuration/usemessageresponsetext
Value : True
Name : urn:schemas:calendar:timezoneid
Value : 1
New server:
Name : http://schemas.microsoft.com/cdo/configuration/languagecode
Value : en-gb
Name : http://schemas.microsoft.com/cdo/configuration/postusing
Value : 0
Name : http://schemas.microsoft.com/cdo/configuration/sendusing
Value : 0
Name : http://schemas.microsoft.com/cdo/configuration/usemessageresponsetext
Value : True
Name : urn:schemas:calendar:timezoneid
Value : 0
It seems that all I need to do to make this work is either configure it to by default send mail to localhost, or to drop the mail in the pickup directory. The IIS SMTP server is already configured to look at this directory.
However, I am unable to figure out where these values are set. They must be set in a file or the registry somewhere but even searching through the C drive looking for phrases like "\Pickup" and "usemessageresponsetext" and so on have not revealed anything. If they are somewhere I guess they're in a binary datastore somewhere.
All samples for CDOSYS involve configuring the CDO.Configuration or CDO.Message instance directly but all throughout the code our application loads the configuration from IIS, so somehow this was set at one point by someone.
I missed out on the classic ASP era so I am in very unfamiliar territory. That said, my coworkers who were active classic ASP developers do not know how to configure this, and the original person who set this up has since moved on. It's entirely possible that I'm missing a very simple basic concept here.
I discovered that I was able to use my sample Powershell script when I was logged in as an administrator. Research from that lead me to a post on the IIS forums which has a solution for the issue. Unfortunately it now leads to some dead links which mean it doesn't work. It had enough hints however to put together a solution:
C:\Program Files (x86)\IIS Resources\Metabase Explorer\MBExplorer.exe
as an administrator./LM/SmtpSvc
, right-click on it and select Properties./LM/SmtpSvc/1
, and set the same permissions on this node also.c:\inetpub\mailroot
So, the root cause was that the user I was trying to execute this under did not have the correct permissions.
Regrettably I couldn't figure out how to script these steps. The post makes reference to a "metaacl.vbs" script that I couldn't find anywhere; all links that claim to have it are dead. It's also meant to be installed by the IIS Resource Kit tools linked above but I couldn't find it anywhere on my server.
If you could find that somewhere you'd be able to perform the above steps like so:
cscript metaacl.vbs IIS://LOCALHOST/SMTPSVC %computername%\IIS_IUSRS R
cscript metaacl.vbs IIS://LOCALHOST/SMTPSVC/1 %computername%\IIS_IUSRS R