Send Email with CDonts and C#

  • Thread starter microsoft.public.dotnet.languages.csharp
  • Start date
M

microsoft.public.dotnet.languages.csharp

ASP.Net, C#, Email message, CDonts not CDO

I am writing an ASP.Net application where I cannot use CDO. I must use
CDonts. I cannot find an example of this on the Internet. I only see
examples on how to do this using CDO. Unfortunately, I don't have that
option. I must use C# and CDonts. Do you have any ideas or code?

In traditional ASP, the code was:
objMail = Server.CreateObject("CDONTS.NewMail");
objMail.To = "(e-mail address removed)";
objMail.From = "(e-mail address removed)";
objMail.Subject = "Test";
objMail.Importance = 2;
objMail.MailFormat = 0;
objMail.BodyFormat = 0;
objMail.Body = "Test message";
objMail.Send;

How is that ported to .Net? What do you declare the objMail variable?
I tried it as an object variable and .Net didn't like it.

Thanks,
Marty

Dont reply to this email...it is fake.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Marty,

You can either:

a) Use the System.Web.Mail namespace to send mail through the .NET managed
wrapper for CDO.
b) Add a COM reference to cdonts.dll to your project. This will add a new
namespace, most likely
"cdonts", where the NewMailClass type will appear and you will then use this
class as any usual
..NET class.
 

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

Top