When MailMessage.BodyFormat = MailFormat.Html, SmtpMail.Send throws exception

A

Aren Cambre

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 SP2,
and IIS's SMTP and WWW servers are installed.

Here is the error trace:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestArea.suq.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testarea\suq.aspx.cs:line 69
----------------------
InnerException:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestArea.suq.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testarea\suq.aspx.cs:line 69
----------------------
InnerException:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)

Here is my code:
MailMessage mailMessage = new MailMessage();

mailMessage.To = "(e-mail address removed)";
mailMessage.Subject = "This bug sucks ass.";
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.Body = "aaaaa";
mailMessage.From = "(e-mail address removed)";

SmtpMail.SmtpServer.Insert(0, "www.smu.edu");
try
{
SmtpMail.Send(mailMessage);
}
catch (Exception ex)
{
Response.Write("<pre>");
Response.Write(ex.ToString());

while (ex.InnerException != null)
{
Response.Write("\n----------------------\n");
Response.Write("InnerException:\n" + ex.ToString());
ex = ex.InnerException;
}
Response.Write("</pre");
}

Any clues?

Aren
 
B

bruce barker

the error message is generic, any error in CDO causes it. does textmode
work? does html work if you send valid html?

-- bruce (sqlwork.com)


Aren Cambre said:
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 SP2,
and IIS's SMTP and WWW servers are installed.

Here is the error trace:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestArea.suq.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testarea\suq.aspx.cs:line 69
----------------------
InnerException:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestArea.suq.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testarea\suq.aspx.cs:line 69
----------------------
InnerException:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)

Here is my code:
MailMessage mailMessage = new MailMessage();

mailMessage.To = "(e-mail address removed)";
mailMessage.Subject = "This bug sucks ass.";
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.Body = "aaaaa";
mailMessage.From = "(e-mail address removed)";

SmtpMail.SmtpServer.Insert(0, "www.smu.edu");
try
{
SmtpMail.Send(mailMessage);
}
catch (Exception ex)
{
Response.Write("<pre>");
Response.Write(ex.ToString());

while (ex.InnerException != null)
{
Response.Write("\n----------------------\n");
Response.Write("InnerException:\n" + ex.ToString());
ex = ex.InnerException;
}
Response.Write("</pre");
}

Any clues?

Aren
 
A

Aren Cambre

bruce barker said:
the error message is generic, any error in CDO causes it. does textmode
work? does html work if you send valid html?

Text mode worked fine.

This is very, very strange: I rebooted my computer, and HTML mode
works fine now. Maybe I've run into an intermittent bug?

Aren
 
S

Seunghyun Kim

I have same problem too. When I set textmode it works fine, but I set
htmlmode it cause 'cdo.message' exception. My development enviroments
are Windows XP (not sp2) & Visual Studio 2002. Is there anyone to help
it?
 
G

Guest

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 SP2,
and IIS's SMTP and WWW servers are installed.

Here is the error trace:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestArea.suq.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testarea\suq.aspx.cs:line 69
----------------------
InnerException:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestArea.suq.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testarea\suq.aspx.cs:line 69
----------------------
InnerException:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040605): Unknown
Error
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object
obj, String propName, Object propValue)
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)

Here is my code:
MailMessage mailMessage = new MailMessage();

mailMessage.To = "(e-mail address removed)";
mailMessage.Subject = "This bug sucks ass.";
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.Body = "aaaaa";
mailMessage.From = "(e-mail address removed)";

SmtpMail.SmtpServer.Insert(0, "www.smu.edu");
try
{
SmtpMail.Send(mailMessage);
}
catch (Exception ex)
{
Response.Write("<pre>");
Response.Write(ex.ToString());

while (ex.InnerException != null)
{
Response.Write("\n----------------------\n");
Response.Write("InnerException:\n" + ex.ToString());
ex = ex.InnerException;
}
Response.Write("</pre");
}

Any clues?

Aren

User submitted from AEWNET (http://www.aewnet.com/)
 

vdk

Joined
Nov 20, 2008
Messages
3
Reaction score
0
MailFormat.Html throws exception and not working

For this to get fixed you can add CDOSYS.dll as refernce to your asp.net application and build the solution and run it should work and will not throw exception.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top