How can I send email from a WebForm?

  • Thread starter Thread starter dee
  • Start date Start date
D

dee

Hi
I tired to use
<form id="Form1" method="post" enctype="text/plain"
action="mailto:[email protected]">
leavin runat="server in then out.
When I took runat="server out this poped a new mail message but it the
message didn;t
containd any values from the WebForm. Also I prefer to send it without
having to have
the new message pop up.
Thanks.
Dee
 
Hi dee,

A WebForm is a Server Control. If you remove the "runat=server" from the
form, it is no longer a Server Control, and the Server Controls in it will
not work. This is part of the ASP.Net programming model. It would be a good
idea to familiarize yourself with the ASP.Net programming model to avoid
many headaches in the future.

In this case, you would need to do a PostBack, and handle the form in your
server-side Page class. Use the System.Web.Mail namespace and related
classes to compose and send the email. Once you get familiar with this, you
will be much happpier as you will also have full control over the email, and
be able to format it any way you like.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Kevin,
Great reply, thanks a lot.
Dee

Kevin Spencer said:
Hi dee,

A WebForm is a Server Control. If you remove the "runat=server" from the
form, it is no longer a Server Control, and the Server Controls in it will
not work. This is part of the ASP.Net programming model. It would be a
good idea to familiarize yourself with the ASP.Net programming model to
avoid many headaches in the future.

In this case, you would need to do a PostBack, and handle the form in your
server-side Page class. Use the System.Web.Mail namespace and related
classes to compose and send the email. Once you get familiar with this,
you will be much happpier as you will also have full control over the
email, and be able to format it any way you like.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.
 

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

Back
Top