I know that this has been asked before; and not only that, I know that it has been answered (successfully) as I myself have previously resolved the problem (with help) - however, I cannot for the life of me remember what the solution was.
I am trying to send an email from an ASP.net application. If I send the email with the MailMessage.Bod yFormat = MailFormat.Text then it sends fine; if I set MailMessage.Bod yFormat = MailFormat.Html then I get the following exception:
COMException (0x80040605): Unknown Error]
[TargetInvocatio nException: Exception has been thrown by the target of an invocation.]
System.RuntimeT ype.InvokeDispM ethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters ) +0
System.RuntimeT ype.InvokeMembe r(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifi er[] modifiers, CultureInfo culture, String[] namedParameters ) +473
System.Type.Inv okeMember(Strin g name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29
System.Web.Mail .LateBoundAcces sHelper.SetProp (Type type, Object obj, String propName, Object propValue)
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String propName, Object propValue)
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String propName, Object propValue)
System.Web.Mail .CdoSysHelper.S end(MailMessage message)
System.Web.Mail .SmtpMail.Send( MailMessage message)
My code is simple:
// Prepare the message to be sent ...
MailMessage mailMessage = new MailMessage();
mailMessage.To = "martin.robins@ ..."; // Changed to avoid spam
mailMessage.Fro m = "emails@... "; // Changed to avoid spam
mailMessage.Sub ject = "My email";
mailMessage.Bod yFormat = MailFormat.Html ;
mailMessage.Bod y = "<html><body>We lcome<P>New line text<BR>Another line</P></body></html>";
SmtpMail.SmtpSe rver = "MyServer";
SmtpMail.Send(m ailMessage);
I am using Framework 1.1 on Windows/XP Pro - I also have Office 2003 installed (I seem to recall that this is relevant)
All help gratefully accepted. I have already tried the usual candidates (MS Knowledgebase, systemwebmail.c om etc.) and I cannot find the answer on there. I have also tried catching the exception and looking for inner exceptions; I cannot identify any further information from them than is shown above!
Thanks.