. NET Beta2 Operation Email example (turn)

Source: Internet
Author: User
Tags mail servervariables
<%@ Page language= "VB" clienttarget= "downlevel"%>
<%@ Import namespace= "System.Web.Mail"%>

<script language= "VB" runat= "Server" >
Sub Btnsendmail_onclick (Source as Object, E as EventArgs)
Dim Mymessage as New mailmessage
Dim MyMail as New smtpmail
Dim Stremail as String

If Page.IsValid () Then
Stremail = Txtemail.text

Mymessage.from = "webmaster@" & Request.ServerVariables ("SERVER_NAME")
Mymessage.to = Stremail
Mymessage.subject = "e-mail Sample from ASP 101!"
Mymessage.body = "This message is sent from sample code by" & _
"Http://www.asp101.com. It is used to show people "& _
"To send e-mail from a asp+ page." This mail is sent "& _
"From" & Request.ServerVariables ("SERVER_NAME") &. "& _
VbCrLf & VbCrLf & _
"This email is sent to" & Stremail & "."

Mymail.send (Mymessage)

Frmemail.visible = False
Lblusermessage.text = "Your message has been sent to" & Stremail & "."
End If
End Sub
</script>

<title>asp+ Email sample</title>
<body>

<asp:label id= "Lblusermessage" text= "Enter your e-mail address:" runat= "Server"/>
<form method= "POST" id= "Frmemail" runat= "Server" >
<asp:textbox id= "Txtemail" size= runat= "Server"/>
<asp:requiredfieldvalidator runat= "Server"
Id= "validemailrequired" controltovalidate= "Txtemail"
Errormessage= "Please enter a email address."
display= "Dynamic"/>
<asp:regularexpressionvalidator runat= "Server"
Id= "Validemailregexp" controltovalidate= "Txtemail"
Validationexpression= "^[\w-]+@[\w-]+\. (com|net|org|edu|mil) $ "
Errormessage= "Please enter a valid e-mail address."
display= "Dynamic"/>

<asp:button id= "Btnsendmail" text= "Send mail!" onclick= "Btnsendmail_onclick" runat= "Server"/>
</form>

</body>
-------------------------------------------
Come from asp101.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.