Help! I can't send email through System.Web.Mail.SmtpMail when useris not an 'Administrator'

  • Thread starter Thread starter Tim Mavers
  • Start date Start date
T

Tim Mavers

I have written a simple Windows Service (C#) that occassionally needs to
send out emails. Due to the security requirements from my client, I
need to run the service with as little security rights as possible. So
far I have managed to get the service running if the user is a member of
the "Power Users" group, which I think will be ok security-wise.

The problem is when the service attempts to send out an email, I get the
following errors (I am including all the InnerException messages in
hopes that it might help). I am also running the standard Microsoft
SMTP server that ships with IIS.

--- Exception Messages ---

System.Web.Exception = "Could not access 'CDO.Message' object."

_InnerException = "Exception has been thrown by the target of an
invocation."

_InnerException = "The "SendUsing" configuration value is invalid."

---------- End -----------

If I add the user (that the service runs under) to the Administrators
group, the email is sent out successfully _every time_ without any
problems, so I know that my SmtpMail code is correct and this is really
some odd permission/privilege problem.

Unfortunately, I can't suggest that using an Administrator account to
run this service as a requirement for my service unless Microsoft
explicity documents that you need Admin rights to send email using .NET/CDO.

I have checked the \inetpub\mailroot and have given FULL-ACCESS rights
to the user so that's the not the problem. Being a Power-User also to
seems to give R/W access to the C:\Windows tree (where CDO.SYS is
located), so I am at a loss from a file-system security perspective.

Finally, I am using Windows XP Pro SP1 (with latest SP1), but am only
using .NET 1.0 (sp2) -- v1.0.3705.364 -- again due to client limitations.

Searching Google, I have found that many people encounter the same
problem (at least the same top-level error), however I have been unable
to find a definitive answer other than make the user an Administrator or
update the machine.config (I am not using ASP.NET so this is not
applicable).

Thanks for any help,
 
I recently went thru a similar issue. In my case it wasn't so much
Administrator rights as the privileges to use the SMTPServer. Did you try
setting your SmtpMail.SmtpServer to the Mail/Exchange server? And beyond
that: is the Mail/Exchange server running the SMTP Service?
 
Bryan said:
I recently went thru a similar issue. In my case it wasn't so much
Administrator rights as the privileges to use the SMTPServer. Did you try
setting your SmtpMail.SmtpServer to the Mail/Exchange server? And beyond
that: is the Mail/Exchange server running the SMTP Service?

Right now I am trying to use the basic Microsoft SMTP Service that ships
with IIS. The mail server is running on the machine and I can send
email (through .NET) as long as the user who is running the service (my
application runs as a service) is a member of the Administrators group.

If the user is _not_ a member of the Administrators group, it fails with
the error messages I previously mentioned. The goal is to get it to
work on the local machine as that is how the client will probably be
using it.

Oddly enough, if I set the SmtpMail.SmtpServer to "localhost" or
"127.0.0.1" which _should_ work, I get an exception (even when the user
is an Administrator) saying that the "Transport could not find the
server" or something like that. That's very odd, so I left it blank (as
the doc states if the SmtpServer property is left blank, it will attempt
to use the SMTP server on the local machine.

I was also successful in manually sending an email through the local
SMTP server by telnetting to localhost port 25 and typing in the SMTP
command manually.

Any other ideas? Is there something I need to set within the SMTP
server (through the MMC plug-in) that allows access? Since I am on an
intranet, I am using the default "allow anonymous connections".

Thanks for your quick reply!
 
Bryan said:
Try this website: http://systemwebmail.com Specifically check out section 4.
This ultimately helped me resolve my issues with this about 3 weeks ago.

Good luck!

Thanks for that link! That is an awesome site, going over all the
possible errors, I found that it was an IIS metabase permissions issue!

Thanks again for the help, you saved me so much time!

Tim
 
Back
Top