WebMail Not Working! "Could not access 'CDO.Message' object"

J

Jason

I am trying to send mail via SMTP, using VB.NET on XP. I keep getting this
error: "Could not access 'CDO.Message' object." (I can send mail fine via
VB6, using CDONTS.)

I have added a reference to System.Web, and this is my code:

Try

WebMailMessage.From = Sender

WebMailMessage.To = Recipient

WebMailMessage.Body = Body

WebMailMessage.Subject = Subject

WebMail.SmtpServer = "localhost" 'Tried SMTPServerString and IP Number as
well

WebMail.Send(WebMailMessage)

Catch e As System.Exception

Debug.Write(e.Message)

MsgBox("SendMailMessage failed with the following exception:" & e.Message)

End Try


All of the values are passed by the class I wrote (Sender, Body, etc.). I
have tried switching the SMTP Server value to the name of my SMTP server,
and to its IP number, but I keep getting the same error. Do I need to add a
COM reference to CDO in my project or what?
 
G

Greg Burns

Check out:

http://www.systemwebmail.net/

You have added a reference to System.Web right?

If using SmtpServer = "localhost" you also have to setup your SMTP server on
the machine running your code to allow relaying to 127.0.0.1 (Look in
IIS->Default-SMTP->Properties->Access tab->Relay->Add 127.0.0.1)

HTH,
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top