Using the procedure below on an ordinary form works fine. Moving it to
a service-project makes it fail on SmtpMail.Send(mail) with error:
"Could not access 'CDO Message' object."
Google-search shows other with similar problems when running in a
service, but I didn't reach a solution.
Any ideas as to what might be wrong?
Using the System.Web.Mail:
Sub SendMail(ByVal SendTo As String, ByVal Capacity As Int64)
WriteLog("sendmail triggered")
Try
Dim mail As New MailMessage
mail.To = Modtager
mail.From = "me"
mail.Subject = "Alert: lack of space"
mail.Body = "Space left: " & Capacity & "MB"
SmtpMail.SmtpServer = mySMTPserver
SmtpMail.Send(mail)
Catch ex As Exception
WriteLog("Email error: " & ex.Message)
End Try
End Sub
Regards /snedker