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
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