Send ing Email with CDonts and C#

M

Marty

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 in C#? What do you declare the objMail
variable? I tried it as an object variable and .Net didn't like it.

Thanks,
Marty
 
K

Kapil

i think this may help u.

kapil


<%@ Import Namespace="System.Web.Mail" %>
<script language="c#" runat="server">
private void btnSend_Click(object sender, System.EventArgs e)
{

MailMessage msg = new MailMessage();

msg.To = txtTo.Text;
msg.From = txtFrom.Text;
msg.Subject = txtSubject.Text;
msg.Body = txtContent.Value;


lblStatus.Text = "Sending...";
SmtpMail.Send(msg);
lblStatus.Text = "Sent email (" + txtSubject.Text + ") to "
+txtTo.Text;
}
</script>
 

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

Similar Threads

Send Email with CDonts and C# 2
Create Email That Allow Accept/Decline to Calendar 1
Cdo errors 3
a form to email 2
request.form 2
feedback form using ASP.NET and VB.NET 1
email doesn't get sent 2
Help with CDO 6

Top