By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

Sending HTML Mail with ASP.NET 1.1

P: n/a
Hi all

I'm sending email via ASP.NET in HTML mode. Each email has exactly one
attachment and I do have full access to the SMTP server. However, if I
send the email in HTML format, the framework reports the following
exception:
"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\r\n --- End of inner exception stack trace ---\r\n at
System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)\r\n at
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[]
modifiers, CultureInfo culture, String[] namedParameters)\r\n at
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String
propName, Object propValue)\r\n --- E
nd of inner exception stack trace ---\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String
propName, Object propValue)\r\n at
System.Web.Mail.CdoSysHelper.Send(MailMessage message)\r\n at
System.Web.Mail.SmtpMail.Send(MailMessage message)\r\n at
XYZ.Utils.SendEmail(MailMessage Message, String SMTPServer) in
c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 406\r\n at
XYZ.Utils.SendEmail(String From, String To, String Bcc, String Cc,
String Subject, String Body, String[] Attachments, MailFormat Format,
String SMTPServer) in c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 392\r\n
at XYZ.Utils.SendEmail(String From, String To, String Bcc, String Cc,
String Subject, String Body, String[] Attachments, MailFormat Format) in
c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 396\r\n at
XYZ.Email.butSend_Click(Object sender, EventArgs e) in
c:\\inetpub\\wwwroot\\XYZ\\email.aspx.cs:line 178"

However, sending in plain text works perfectly.
Any ideas?

Regards
Ray
May 21 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
I'm not sure what you are doing wrong since you haven't shown us your source
code, but try following this tutorial in sending HTML emails with
attachements:

http://www.geekpedia.com/tutorial124...-ASP-.NET.html

Best regards,
Andrei

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi all

I'm sending email via ASP.NET in HTML mode. Each email has exactly one
attachment and I do have full access to the SMTP server. However, if I
send the email in HTML format, the framework reports the following
exception:
"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\r\n --- End of inner exception stack trace ---\r\n at
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters)\r\n at System.RuntimeType.InvokeMember(String
name, BindingFlags invokeAttr, Binder binder, Object target, Object[]
args, ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)\r\n at System.Type.InvokeMember(String name,
BindingFlags invokeAttr, Binder binder, Object target, Object[] args)\r\n
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String propName,
Object propValue)\r\n --- E
nd of inner exception stack trace ---\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String propName,
Object propValue)\r\n at System.Web.Mail.CdoSysHelper.Send(MailMessage
message)\r\n at System.Web.Mail.SmtpMail.Send(MailMessage message)\r\n
at XYZ.Utils.SendEmail(MailMessage Message, String SMTPServer) in
c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 406\r\n at
XYZ.Utils.SendEmail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format, String
SMTPServer) in c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 392\r\n at
XYZ.Utils.SendEmail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format) in
c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 396\r\n at
XYZ.Email.butSend_Click(Object sender, EventArgs e) in
c:\\inetpub\\wwwroot\\XYZ\\email.aspx.cs:line 178"

However, sending in plain text works perfectly.
Any ideas?

Regards
Ray

May 22 '06 #2

P: n/a
"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
I'm sending email via ASP.NET in HTML mode. Each email has exactly one
attachment and I do have full access to the SMTP server. However, if I
send the email in HTML format, the framework reports the following
exception:


http://www.systemwebmail.com
May 22 '06 #3

P: n/a
Mark Rae wrote:
"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
I'm sending email via ASP.NET in HTML mode. Each email has exactly one
attachment and I do have full access to the SMTP server. However, if I
send the email in HTML format, the framework reports the following
exception:


http://www.systemwebmail.com

I've seen that but none of the ideas work. ;)

Thanks though.
May 22 '06 #4

P: n/a
Hi Andrei

Here is the method:

public static void SendEmail(MailMessage Message, string SMTPServer) {
if (SMTPServer != "")
SmtpMail.SmtpServer = SMTPServer;
SmtpMail.Send(Message);
}

Which is called by an overloaded method:

public static void SendEmail(string From, string To, string Bcc, string
Cc, string Subject, string Body, string[] Attachments,
System.Web.Mail.MailFormat Format, string SMTPServer)
{
MailMessage _mm = new MailMessage();
_mm.From = From;
_mm.To = To;
_mm.Subject = Subject;
_mm.Body = Body;
_mm.BodyFormat = Format;
_mm.Cc = Cc;
_mm.Bcc = Bcc;

foreach (string s in Attachments)
_mm.Attachments.Add(new System.Web.Mail.MailAttachment(s));
SendEmail(_mm, SMTPServer);
}

Andrei Pociu wrote:
I'm not sure what you are doing wrong since you haven't shown us your source
code, but try following this tutorial in sending HTML emails with
attachements:

http://www.geekpedia.com/tutorial124...-ASP-.NET.html

Best regards,
Andrei

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
Hi all

I'm sending email via ASP.NET in HTML mode. Each email has exactly one
attachment and I do have full access to the SMTP server. However, if I
send the email in HTML format, the framework reports the following
exception:
"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\r\n --- End of inner exception stack trace ---\r\n at
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters)\r\n at System.RuntimeType.InvokeMember(String
name, BindingFlags invokeAttr, Binder binder, Object target, Object[]
args, ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)\r\n at System.Type.InvokeMember(String name,
BindingFlags invokeAttr, Binder binder, Object target, Object[] args)\r\n
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String propName,
Object propValue)\r\n --- E
nd of inner exception stack trace ---\r\n at
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String propName,
Object propValue)\r\n at System.Web.Mail.CdoSysHelper.Send(MailMessage
message)\r\n at System.Web.Mail.SmtpMail.Send(MailMessage message)\r\n
at XYZ.Utils.SendEmail(MailMessage Message, String SMTPServer) in
c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 406\r\n at
XYZ.Utils.SendEmail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format, String
SMTPServer) in c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 392\r\n at
XYZ.Utils.SendEmail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format) in
c:\\inetpub\\wwwroot\\XYZ\\utils.cs:line 396\r\n at
XYZ.Email.butSend_Click(Object sender, EventArgs e) in
c:\\inetpub\\wwwroot\\XYZ\\email.aspx.cs:line 178"

However, sending in plain text works perfectly.
Any ideas?

Regards
Ray


May 22 '06 #5

P: n/a
"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I've seen that but none of the ideas work. ;)


You're not using McAfee VirusScan, are you...?
May 22 '06 #6

P: n/a
Mark Rae wrote:
"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I've seen that but none of the ideas work. ;)


You're not using McAfee VirusScan, are you...?

Nope, but I think I've got the issue, but not the solution. IIS is
running on my laptop for my dev environment. I was working from home
this weekend with the SMTP virtual server set to forward to the server
at the office. It seems the SMTP server doesn't like relaying over the
VPN for some reason as today it is working perfectly.

Regards
Ray
May 22 '06 #7

P: n/a
Ray Booysen wrote:
Mark Rae wrote:
"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I've seen that but none of the ideas work. ;)


You're not using McAfee VirusScan, are you...?

Nope, but I think I've got the issue, but not the solution. IIS is
running on my laptop for my dev environment. I was working from home
this weekend with the SMTP virtual server set to forward to the server
at the office. It seems the SMTP server doesn't like relaying over the
VPN for some reason as today it is working perfectly.

Regards
Ray

OK wait, I lie. Same issues occurring on another machine.
May 22 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.