473,609 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending HTML Mail with ASP.NET 1.1

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.Htt pException: Could not access 'CDO.Message' object. --->
System.Reflecti on.TargetInvoca tionException: 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.RuntimeT ype.InvokeDispM ethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters )\r\n at
System.RuntimeT ype.InvokeMembe r(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifi er[]
modifiers, CultureInfo culture, String[] namedParameters )\r\n at
System.Type.Inv okeMember(Strin g name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Type type, Object obj,
String propName, Object propValue)\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String
propName, Object propValue)\r\n --- E
nd of inner exception stack trace ---\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String
propName, Object propValue)\r\n at
System.Web.Mail .CdoSysHelper.S end(MailMessage message)\r\n at
System.Web.Mail .SmtpMail.Send( MailMessage message)\r\n at
XYZ.Utils.SendE mail(MailMessag e Message, String SMTPServer) in
c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 406\r\n at
XYZ.Utils.SendE mail(String From, String To, String Bcc, String Cc,
String Subject, String Body, String[] Attachments, MailFormat Format,
String SMTPServer) in c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 392\r\n
at XYZ.Utils.SendE mail(String From, String To, String Bcc, String Cc,
String Subject, String Body, String[] Attachments, MailFormat Format) in
c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 396\r\n at
XYZ.Email.butSe nd_Click(Object sender, EventArgs e) in
c:\\inetpub\\ww wroot\\XYZ\\ema il.aspx.cs:line 178"

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

Regards
Ray
May 21 '06 #1
7 4382
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******** **********@TK2M SFTNGP04.phx.gb l...
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.Htt pException: Could not access 'CDO.Message' object. --->
System.Reflecti on.TargetInvoca tionException: 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.RuntimeT ype.InvokeDispM ethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters )\r\n at System.RuntimeT ype.InvokeMembe r(String
name, BindingFlags invokeAttr, Binder binder, Object target, Object[]
args, ParameterModifi er[] modifiers, CultureInfo culture, String[]
namedParameters )\r\n at System.Type.Inv okeMember(Strin g name,
BindingFlags invokeAttr, Binder binder, Object target, Object[] args)\r\n
at System.Web.Mail .LateBoundAcces sHelper.SetProp (Type type, Object obj,
String propName, Object propValue)\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String propName,
Object propValue)\r\n --- E
nd of inner exception stack trace ---\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String propName,
Object propValue)\r\n at System.Web.Mail .CdoSysHelper.S end(MailMessage
message)\r\n at System.Web.Mail .SmtpMail.Send( MailMessage message)\r\n
at XYZ.Utils.SendE mail(MailMessag e Message, String SMTPServer) in
c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 406\r\n at
XYZ.Utils.SendE mail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format, String
SMTPServer) in c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 392\r\n at
XYZ.Utils.SendE mail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format) in
c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 396\r\n at
XYZ.Email.butSe nd_Click(Object sender, EventArgs e) in
c:\\inetpub\\ww wroot\\XYZ\\ema il.aspx.cs:line 178"

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

Regards
Ray

May 22 '06 #2
"Ray Booysen" <rj***********@ rjb.za.net> wrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
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
Mark Rae wrote:
"Ray Booysen" <rj***********@ rjb.za.net> wrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
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
Hi Andrei

Here is the method:

public static void SendEmail(MailM essage Message, string SMTPServer) {
if (SMTPServer != "")
SmtpMail.SmtpSe rver = SMTPServer;
SmtpMail.Send(M essage);
}

Which is called by an overloaded method:

public static void SendEmail(strin g 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******** **********@TK2M SFTNGP04.phx.gb l...
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.Htt pException: Could not access 'CDO.Message' object. --->
System.Reflecti on.TargetInvoca tionException: 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.RuntimeT ype.InvokeDispM ethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters )\r\n at System.RuntimeT ype.InvokeMembe r(String
name, BindingFlags invokeAttr, Binder binder, Object target, Object[]
args, ParameterModifi er[] modifiers, CultureInfo culture, String[]
namedParameters )\r\n at System.Type.Inv okeMember(Strin g name,
BindingFlags invokeAttr, Binder binder, Object target, Object[] args)\r\n
at System.Web.Mail .LateBoundAcces sHelper.SetProp (Type type, Object obj,
String propName, Object propValue)\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String propName,
Object propValue)\r\n --- E
nd of inner exception stack trace ---\r\n at
System.Web.Mail .LateBoundAcces sHelper.SetProp (Object obj, String propName,
Object propValue)\r\n at System.Web.Mail .CdoSysHelper.S end(MailMessage
message)\r\n at System.Web.Mail .SmtpMail.Send( MailMessage message)\r\n
at XYZ.Utils.SendE mail(MailMessag e Message, String SMTPServer) in
c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 406\r\n at
XYZ.Utils.SendE mail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format, String
SMTPServer) in c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 392\r\n at
XYZ.Utils.SendE mail(String From, String To, String Bcc, String Cc, String
Subject, String Body, String[] Attachments, MailFormat Format) in
c:\\inetpub\\ww wroot\\XYZ\\uti ls.cs:line 396\r\n at
XYZ.Email.butSe nd_Click(Object sender, EventArgs e) in
c:\\inetpub\\ww wroot\\XYZ\\ema il.aspx.cs:line 178"

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

Regards
Ray


May 22 '06 #5
"Ray Booysen" <rj***********@ rjb.za.net> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
I've seen that but none of the ideas work. ;)


You're not using McAfee VirusScan, are you...?
May 22 '06 #6
Mark Rae wrote:
"Ray Booysen" <rj***********@ rjb.za.net> wrote in message
news:%2******** ********@TK2MSF TNGP04.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
Ray Booysen wrote:
Mark Rae wrote:
"Ray Booysen" <rj***********@ rjb.za.net> wrote in message
news:%2******** ********@TK2MSF TNGP04.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1734
by: prasanna | last post by:
Hello I tried to send mail from PHP in html format. But an ! mark appears in mail body in Inbox. I tried to print body text on page before sending mail and it does not show ! mark. I replaced ! mark from mail body before passing it to mail() function but then also it adds ! mark in mail body. Can you please tell me why this is happening? Thanks
4
2962
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text email by creating a text file, with content following certain format, and saving that file into the correct '..\mailroot\pickup' folder, and it is working fine
2
1746
by: Paul Turley | last post by:
Does anyone have some sample code for sending an HTML formatted message using CDONTS? Thanks RE: Sending HTML formatted mail using CDONTS -- Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
2
9218
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends - I see hebrew, it is just sending by myself using *.aspx scripts). In web.config I have the following : <configuration> <system.web>
6
2408
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
6
2736
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
2
2670
by: ChrisA | last post by:
I'm sending email from my ASP.NET 1.1 app, and it works fine providing the BodyFormat of the System.Web.Mail.MailMessage is set to Text. If I change to Html format, it breaks. Here's the code: Me.Msg = New System.Web.Mail.MailMessage With Me.Msg .To = "someToAddress"
7
9781
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to achieve this. Thanks
3
2707
by: virtualweb | last post by:
Hello: I need to send a bit of HTML and Javascrpt on the body of an email from my perl script in order to have the recipient get a link that will openup a new window with a PopUp. For some reason instead of receiving the email with the HTML showing a link that will open up my PopUp... Im getting all the HTML tags and javasacript code printed on my email. What am I doing wrong..?? Here is the code:
0
8127
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8527
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8215
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6053
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5509
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4015
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1380
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.