Tuesday, June 07, 2005
Could not access 'CDO.Message' object.
About 2 years back I wrote a windows (not asp.net) program that is a scheduled task to perform a weekly database check and send some emails. I was told that about 6 months or so ago it stopped working. This is the problem:
While this fixed the problem, the reason for the problem is not immediate, and I only have a few guesses. Perhaps version 1.1 of .NET created some new security setting or changed the defaults for how to send mail. Perhaps someone changed our email server's settings. Only the former seems reasonable because SMTP authentication was never enabled before. The other odd thing here is the fact that it worked just fine under my username, which happens to match my email address username. There is no Administrator@ourdomain.com email account, which might be why it fails under the Administrator account. While that sounds reasonable, there is no reason that the windows account name should matter when sending email, especially when the email server software is not from Microsoft. Furthermore, my account password on the server does not match my email account password, so it could never authenticate automatically between the two anyway.
I guess that's the problem with installing all updates from Microsoft. It seems most likely that upgrading the .NET Framework to 1.1 broke it. Who knows what 2.0 will bring.
- When running the program under my username (a member of the Administrators group), it worked fine.
- When running the program under the Administrator username, it crashed with the mysterious "Could not access 'CDO.Message' object." error. I need it to work under the Administrator account for the scheduled tasks, and because I won't be working here in a few months and my account may be disabled in the future.
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0")This line of code sets SMTP authentication for this message to be 0 (no authentication / anonymous). This is what I need since I am using what seems to be an unusual configuration (seems typical to me though) of a different server for email and the server does not require SMTP authentication.
While this fixed the problem, the reason for the problem is not immediate, and I only have a few guesses. Perhaps version 1.1 of .NET created some new security setting or changed the defaults for how to send mail. Perhaps someone changed our email server's settings. Only the former seems reasonable because SMTP authentication was never enabled before. The other odd thing here is the fact that it worked just fine under my username, which happens to match my email address username. There is no Administrator@ourdomain.com email account, which might be why it fails under the Administrator account. While that sounds reasonable, there is no reason that the windows account name should matter when sending email, especially when the email server software is not from Microsoft. Furthermore, my account password on the server does not match my email account password, so it could never authenticate automatically between the two anyway.
I guess that's the problem with installing all updates from Microsoft. It seems most likely that upgrading the .NET Framework to 1.1 broke it. Who knows what 2.0 will bring.