Could not access 'CDO.Message' object

  • Thread starter Thread starter Thys Brits
  • Start date Start date
T

Thys Brits

Hi,

I'm using the System.Web.Mail class to send an e-mail from my ASP.Net
application, but when sending the e-mail, I'm getting the above error. It
seems to be because I have Office XP installed, and the version of CDO is
replaced by this installation. I haven't been able to find this error
anywhere on any MS site. Anyone have a clue on how to then actually send the
e-mail?

Thanks

Thys Brits
MCSD/MCAD
 
Hi Thys,

Have you ever sent e-mail successfully with System.Web.Mail class before
you installed the Office XP?
Can you tell me if your smtp server used to send email need client
authentication, which may caused the problem, Since you can not set the
client authentication with the System.Web.Mail class?


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
 
Hi,

I added a reference to Microsoft CDO for Exchange library in my project, and
changed the code to use CDO.MessageClass (and had to change a few
properties, including the Configuration.Fields). This works, although there
are no authentication properties set. I'm using my local SMTP server, and it
worked using the code below (the code is run in a web server control):

CDO.MessageClass mail = new CDO.MessageClass();
mail.Subject = "Record change";
mail.From = "(e-mail address removed))";
mail.HTMLBody = "<HTML><Body><Font Face=\"Arial\" Size=\"2\">";
mail.HTMLBody += "A change has been made to a record in the table <b>" +
strTable + "</b> by " + this.Page.Session["UserName"] + ".<br>";
string sURL = this.Page.Request.Url.ToString();
mail.HTMLBody += "<p>To view the change(s), visit the website at <A href=\""
+ sURL + "\">" + sURL + "</a>.";
mail.HTMLBody += "</Font></Body></HTML>";
mail.BCC = "(e-mail address removed)";
mail.To = recip.Substring(0, recip.Length - 1); //recip is a string
containing all the recipients
mail.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/se
ndusing"].Value = 2;
mail.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/sm
tpserverport"].Value = 25;
if(this.Page.Application["MailServer"] != null)
{

mail.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/sm
tpserver"].Value = this.Page.Application["MailServer"].ToString();
}
mail.Configuration.Fields.Update();
mail.Send();

I haven't tried sending mail before installing Office XP, the only reason I
thought it might be this, is because I found an article on MS website saying
that Office XP replaces the CDO library, and replaces the reference to it in
the registry. Any further ideas?

Thys Brits

PS - I should warn everyone - don't post with your real e-mail address -
since posting my original message, I've been spammed with these stupid
"Microsoft Update" virus e-mails - I've received about 30 in the last 18
hours.... MS should find these people and sue them for identity theft, etc,
etc, etc....
 
For those of you who were wondering about this, I found the solution. It's a
permissions problem. I added the following code at the top of my class, and
it worked!

using System.Security.Permissions;
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, Name =
"LocalIntranet")]

Thys Brits
MCSD/MCSD.Net

Thys Brits said:
Hi,

I added a reference to Microsoft CDO for Exchange library in my project, and
changed the code to use CDO.MessageClass (and had to change a few
properties, including the Configuration.Fields). This works, although there
are no authentication properties set. I'm using my local SMTP server, and it
worked using the code below (the code is run in a web server control):

CDO.MessageClass mail = new CDO.MessageClass();
mail.Subject = "Record change";
mail.From = "(e-mail address removed))";
mail.HTMLBody = "<HTML><Body><Font Face=\"Arial\" Size=\"2\">";
mail.HTMLBody += "A change has been made to a record in the table <b>" +
strTable + "</b> by " + this.Page.Session["UserName"] + ".<br>";
string sURL = this.Page.Request.Url.ToString();
mail.HTMLBody += "<p>To view the change(s), visit the website at <A href=\""
+ sURL + "\">" + sURL + "</a>.";
mail.HTMLBody += "</Font></Body></HTML>";
mail.BCC = "(e-mail address removed)";
mail.To = recip.Substring(0, recip.Length - 1); //recip is a string
containing all the recipients
mail.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/se
ndusing"].Value = 2;
mail.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/sm
tpserverport"].Value = 25;
if(this.Page.Application["MailServer"] != null)
{

mail.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/sm
tpserver"].Value = this.Page.Application["MailServer"].ToString();
}
mail.Configuration.Fields.Update();
mail.Send();

I haven't tried sending mail before installing Office XP, the only reason I
thought it might be this, is because I found an article on MS website saying
that Office XP replaces the CDO library, and replaces the reference to it in
the registry. Any further ideas?

Thys Brits

PS - I should warn everyone - don't post with your real e-mail address -
since posting my original message, I've been spammed with these stupid
"Microsoft Update" virus e-mails - I've received about 30 in the last 18
hours.... MS should find these people and sue them for identity theft, etc,
etc, etc....

Peter Huang said:
Hi Thys,

Have you ever sent e-mail successfully with System.Web.Mail class before
you installed the Office XP?
Can you tell me if your smtp server used to send email need client
authentication, which may caused the problem, Since you can not set the
client authentication with the System.Web.Mail class?


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

-------------------- send
the
 
Back
Top