I get this message when i use either of the codes at the bottom of this thread, can anyone help me out?

The coding that is highlighted in the first code is "End With" and the coding that is highlighted in the second code is "System.Web.Mail.SmtpMail.Send(mailMessage)"

I used to get an error from not having Web.dll as my reference but i fixed that and now this is my problem

Any Ideas?
Thanks a lot
Dan

Error:

An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll

Additional information: Could not access 'CDO.Message' object.

Code Used:

Dim m As New System.Web.Mail.MailMessage()


With m
.From = "[email protected]"
.To = "myself$my.house"
.Subject = "My SMTP Test"
.Body = "My New Message"
End With

SmtpMail.SmtpServer = "www.digitalims.net"
SmtpMail.Send(m)


Or the other code:

Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()
mailMessage.From = "[email protected]"
mailMessage.To = "[email protected]"
mailMessage.Subject = "Email Subject"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text

System.Web.Mail.SmtpMail.SmtpServer = "localhost"
System.Web.Mail.SmtpMail.Send(mailMessage)