01.
<%@ Import
Namespace
=
"System.Web.Mail"
%>
02.
<%@ Page Language=
"VB"
%>
03.
<script runat=
"server"
>
04.
Sub
btnSend_Click(sender
As
Object
, e
As
EventArgs)
05.
Dim
myMail
As
New
MailMessage()
06.
07.
myMail.
To
=
Me
.txtTo.Text
08.
myMail.From =
"<"
&
Me
.txtFromEmail.Text &
">"
&
Me
.txtFromName.Text
09.
myMail.Subject =
Me
.txtSubject.Text
10.
11.
myMail.BodyFormat = MailFormat.HTML
12.
myMail.Body = Replace(
Me
.txtDescription.Text,vbCrLf,
"<br>"
)
13.
14.
SmtpMail.Send(myMail)
15.
16.
myMail =
Nothing
17.
18.
Me
.pnlForm.Visible =
False
19.
Me
.lblText.Text =
"Mail Sending."
20.
End
Sub
21.
22.
</script>
23.
<html>
24.
<head>
25.
<title>ThaiCreate.Com ASP.NET - Send Mail</title>
26.
</head>
27.
<body>
28.
<form id=
"form1"
runat=
"server"
>
29.
<asp:Panel id=
"pnlForm"
runat=
"server"
>
30.
<table width=
"343"
border=
"1"
>
31.
<tr>
32.
<td>
To
</td>
33.
<td><asp:TextBox id=
"txtTo"
runat=
"server"
Width=
"155px"
></asp:TextBox></td>
34.
</tr>
35.
<tr>
36.
<td>Subject</td>
37.
<td><asp:TextBox id=
"txtSubject"
runat=
"server"
></asp:TextBox></td>
38.
</tr>
39.
<tr>
40.
<td>Description</td>
41.
<td><asp:TextBox ID=
"txtDescription"
runat=
"server"
Rows=
"4"
TextMode=
"MultiLine"
></asp:TextBox></td>
42.
</tr>
43.
<tr>
44.
<td>Form Name</td>
45.
<td><asp:TextBox id=
"txtFromName"
runat=
"server"
></asp:TextBox></td>
46.
</tr>
47.
<tr>
48.
<tr>
49.
<td>Form Email</td>
50.
<td><asp:TextBox id=
"txtFromEmail"
runat=
"server"
></asp:TextBox></asp:TextBox></td>
51.
</tr>
52.
<tr>
53.
<td> </td>
54.
<td><asp:Button id=
"btnSend"
onclick=
"btnSend_Click"
runat=
"server"
Text=
"Send"
></asp:Button></td>
55.
</tr>
56.
</table>
57.
</asp:Panel>
58.
<asp:Label id=
"lblText"
runat=
"server"
></asp:Label>
59.
</form>
60.
</body>
61.
</html>