Could not create 'CDO.Message' object

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2006
Posts: 8
Reputation: artee is an unknown quantity at this point 
Solved Threads: 0
artee artee is offline Offline
Newbie Poster

Could not create 'CDO.Message' object

 
0
  #1
Mar 26th, 2007
I am trying to send an email from an ASP.NET application and get the error "Could not create 'CDO.Message' object"
It seems to be some permission error and unfortunately cannot figure it out, hence this post. I tested the same code in a VB.NET application and it works fine and sends the email. The error occurs in the ASP.NET page.
Below is the code that I am using to send the email, and I have also imported the System.Web.Mail class

  1. Dim myMail As New MailMessage
  2.  
  3. myMail.From = "<a href="mailto:mymails@abc.com">mymails@abc.com</a>"
  4. myMail.To = "<a href="mailto:artee@abc.com">artee@abc.com</a>"
  5. myMail.Subject = "this is a test email."
  6. myMail.Body = "Some text goes here"
  7. SmtpMail.SmtpServer = "localhost"
  8. Try
  9. SmtpMail.Send(myMail)
  10. Catch ex As Exception
  11. Response.Write(("The following exception occurred: " + ex.ToString()))
  12. 'check the InnerException
  13. While Not (ex.InnerException Is Nothing)
  14. Response.Write("--------------------------------")
  15. Response.Write(("The following InnerException reported: " + ex.InnerException.ToString()))
  16. ex = ex.InnerException
  17. End While
  18. End Try
  19.  


The Error displayed on the ASPX page is as below
'**********************************
The following exception occurred: System.Web.HttpException: Could not create 'CDO.Message' object. at System.Web.Mail.LateBoundAccessHelper.get_LateBoundType() at System.Web.Mail.LateBoundAccessHelper.CreateInstance() at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at TestEmails.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\TestEmails\MainPage.aspx.vb:line 40
'**********************************

Can you please help. I have been struggling with this the past couple of days trying to set permissions and registering the cdosys.dll, but nothing seems to work
Thanks
- Artee
Last edited by artee; Mar 26th, 2007 at 3:31 pm. Reason: update
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Could not create 'CDO.Message' object

 
0
  #2
Mar 27th, 2007
do you have a mail server on your local machine? you are calling the smtp server on localhost but i suspect the service isnt installed and running. use a known smtp server. then add .net credentials to the smtpmail.

I would also use the system.net.mail namespace rather than the old smtp namespace if you have .net 2 on your pc
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 2
Reputation: amrahne is an unknown quantity at this point 
Solved Threads: 0
amrahne amrahne is offline Offline
Newbie Poster

Re: Could not create 'CDO.Message' object

 
0
  #3
Oct 29th, 2007
I know it is probably too late to help you, but someone else may benefit from this question.
The format is quite different for the cdosys message in asp.net with VB. There is a link here that is good for explaining system.net.mail use in different languages. This is compatible with windows 2003, not 2000. W2K uses the deprecated system.web.mail format.

VisualBasic.NET Syntax (Toggle Plain Text)
  1. 'create the mail message
  2. Dim mail As New MailMessage()
  3.  
  4. 'set the addresses
  5. mail.From = New MailAddress("me@mycompany.com")
  6. mail.To.Add("you@yourcompany.com")
  7.  
  8. 'set the content
  9. mail.Subject = "This is an email"
  10. mail.Body = "this is a sample body"
  11.  
  12. 'send the message
  13. Dim smtp As New SmtpClient("127.0.0.1")
  14. smtp.Send(mail)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC