G
Guest
Hi,
I receive an access denied error (see below) when attempting to send an
email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same
code works fine in a console application, and also succeeds from the asp.net
page with BodyFormat=MailFormat.Text.
I've recently upgraded from W2K SP4 to WinXP SP2 and am using .Net Framework
v1.1 SP1. The code worked fine under W2K SP4.
Any ideas? I've seen the same problem posted on the web a few times but
have not seen a response.
The error:
Server Error in '/WebMailTest' Application.
--------------------------------------------------------------------------------
Unknown Error
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Unknown Error
Source Error:
Line 28:
Line 29: SmtpMail.SmtpServer = "<name removed>";
Line 30: SmtpMail.Send(mm);
Line 31: }
Line 32:
Source File: c:\inetpub\wwwroot\webmailtest\webform1.aspx.cs Line: 30
Stack Trace:
[COMException (0x80040605): Unknown Error]
[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters) +473
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args) +29
System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)
System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
System.Web.Mail.SmtpMail.Send(MailMessage message)
WebMailTest.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\webmailtest\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
The code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
namespace WebMailTest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mm = new MailMessage();
mm.To = "<valid e-mail address removed>";
mm.From = "<valid e-mail address removed>";
mm.Subject="test";
mm.BodyFormat = MailFormat.Html;
mm.Body = "<h1>hello</h1>";
SmtpMail.SmtpServer = "smtp.gb.rothschild.com";
SmtpMail.Send(mm);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
I receive an access denied error (see below) when attempting to send an
email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same
code works fine in a console application, and also succeeds from the asp.net
page with BodyFormat=MailFormat.Text.
I've recently upgraded from W2K SP4 to WinXP SP2 and am using .Net Framework
v1.1 SP1. The code worked fine under W2K SP4.
Any ideas? I've seen the same problem posted on the web a few times but
have not seen a response.
The error:
Server Error in '/WebMailTest' Application.
--------------------------------------------------------------------------------
Unknown Error
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Unknown Error
Source Error:
Line 28:
Line 29: SmtpMail.SmtpServer = "<name removed>";
Line 30: SmtpMail.Send(mm);
Line 31: }
Line 32:
Source File: c:\inetpub\wwwroot\webmailtest\webform1.aspx.cs Line: 30
Stack Trace:
[COMException (0x80040605): Unknown Error]
[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters) +473
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args) +29
System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)
System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
System.Web.Mail.SmtpMail.Send(MailMessage message)
WebMailTest.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\webmailtest\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
The code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
namespace WebMailTest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mm = new MailMessage();
mm.To = "<valid e-mail address removed>";
mm.From = "<valid e-mail address removed>";
mm.Subject="test";
mm.BodyFormat = MailFormat.Html;
mm.Body = "<h1>hello</h1>";
SmtpMail.SmtpServer = "smtp.gb.rothschild.com";
SmtpMail.Send(mm);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}