944,066 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 6003
  • ASP.NET RSS
Mar 26th, 2007
0

Could not create 'CDO.Message' object

Expand Post »
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

ASP.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
artee is offline Offline
8 posts
since Dec 2006
Mar 27th, 2007
0

Re: Could not create 'CDO.Message' object

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
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Oct 29th, 2007
0

Re: Could not create 'CDO.Message' object

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)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amrahne is offline Offline
2 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: need help building radio buttons in a dynamic asp form
Next Thread in ASP.NET Forum Timeline: .value





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC