473,503 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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(Obje ct obj, String
propName, Object propValue)

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct 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
}
}

Feb 24 '06 #1
2 3476
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" <ap****@noemail.noemail> wrote in message
news:C2**********************************@microsof t.com...
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(Obje ct obj, String
propName, Object propValue)

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct 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
}
}


Feb 27 '06 #2
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.)

Feb 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1922
by: marc gold | last post by:
I am trying to create a send html functionality in a windows UI application. And using c# (of course) and the System.Web.Mail objects some sites work (aka www.microsoft.com) and some sites do not...
7
3140
by: Randel Bjorkquist | last post by:
First, I'm extremely new to C# and the Microsoft Visual Studio IDE. I am in the middle of writing a small web application that communicates to a database server and sends out email confirmations. ...
5
2299
by: Yossi Naggar | last post by:
Hello to everyone, Does anybody know how to send html formatted messages with asp.net? I tried to send such messages with the code below but the content type is wrong. The content type is...
1
6329
by: mg | last post by:
I'd like to send a single e-mail message message that uses the escape character \n as well as the html tag <i> in the body How can I combine the two parts of this merssage message.BodyFormat =...
4
7527
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP...
1
1780
by: Sophie | last post by:
Hi, I'm not very good in english so excuse me if I have difficulty to explain my problem. I want to send a mail with VB.net with this code : Option Strict On Public Class Form1 Inherits...
2
3880
by: Husam | last post by:
Hi EveryBody: I made windows application project as e-mail sender. This project consist of 13 textbox and one label and one button. I add {system.web.dll} as refrance to this project to help me...
10
11189
by: Dennis | last post by:
I am trying to send an e-mail using one of the examples I got on this group as follows: (both toemail and myemail are valid e-mail addreses. 'System.Web.Mail' (requires reference to...
4
17436
Frinavale
by: Frinavale | last post by:
Introduction Many .NET applications will require an email be sent out for various reasons. This article will give a quick examples on how to send an email using VB.NET. The examples given can...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.