Send mail using System.Web.Mail fails w/ m.BodyFormat=MailFormat.H

Discussion in 'ASP .Net' started by =?Utf-8?B?Unlhbg==?=, Feb 24, 2006.

  1. 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
    }
    }
     
    =?Utf-8?B?Unlhbg==?=, Feb 24, 2006
    #1
    1. Advertising

  2. Re: Send mail using System.Web.Mail fails w/ m.BodyFormat=MailForm

    Thanks - that site was my first port of call when I experienced the problem
    but to no avail (although someone did raise exactly the same question it
    remains unanswered).

    "Patrick.O.Ige" wrote:

    > Visit www.systemwebmail.com
    > You should get a solution there
    > patrick
    >
    > "Ryan" <> wrote in message
    > news:...
    > > 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
    > > }
    > > }
    > >

    >
    >
    >
     
    =?Utf-8?B?Unlhbg==?=, Feb 27, 2006
    #2
    1. Advertising

  3. Re: Send mail using System.Web.Mail fails w/ m.BodyFormat=MailForm

    Hi Ryan,

    I think this should be a environment specific issue. Are you encountering
    the same problem on some other server? Also, are you sending the email
    through exchange server or a custom smtp server and does that server
    require authentication. In addition, since console application and ASP.NET
    application are running under differernt process identity and logon
    session, I think you can also try make your ASP.NET page use windows
    authenticaion and impersonate the client user to see whether this can make
    the application work. If work, the problem should be related to the
    executing security identity.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Feb 28, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=
    Replies:
    1
    Views:
    2,148
    Marshal Antony
    Feb 8, 2004
  2. Aren Cambre
    Replies:
    5
    Views:
    4,103
  3. =?Utf-8?B?TWVoZGk=?=

    email bodyformat

    =?Utf-8?B?TWVoZGk=?=, Jun 18, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    460
    =?Utf-8?B?TWVoZGk=?=
    Jun 18, 2005
  4. ChrisA
    Replies:
    2
    Views:
    3,049
    ChrisA
    May 6, 2006
  5. Brad
    Replies:
    2
    Views:
    10,213
Loading...

Share This Page