Help! Sending mail from windows service

  • Thread starter Thread starter pseudonym
  • Start date Start date
P

pseudonym

Hi all.

I've got a service that needs to send email if there's a critical failure.
The following code works fine in an otherwise empty service:

Protected Overrides Sub OnStart(ByVal args() As String)
System.Web.Mail.SmtpMail.SmtpServer = "mysmtp.com"
System.Web.Mail.SmtpMail.Send("mysvc", "(e-mail address removed)", "foobar",
"test")
End Sub

However, in the real service, the same two lines of code fail with the error
"Could not access CDO.Message object"
In case it matters, this occurs in an exception handler inside a timer
event.


Can anyone tell me why this might be happening, and how to get around it?


Thanks!
 
Most likely a security issue. Try setting the account that the service runs
under as an administrator account. If it works then you know its a security
issue.

For sending something as simple as a notification you may want to use
http://www.freesmtp.net. Its a lot easier to configure.

Bill
 
Back
Top