Send an email : Email « Components « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Components » Email 
Send an email

<%@ Page Language="VB" %>
<script runat="server">
    
    Sub Button1_Click(sender As Object, e As EventArgs)
      Label1.Text = SendMail("Feedback form", TextBox1.Text, TextBox2.Text)
    End Sub
    
    Function SendMail(Subject As String, FromAddress As String, Message As StringAs String
    
    ' Build a MailMessage
    Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
    mailMessage.From = "[email protected]"
    mailMessage.To = "[email protected]"
    mailMessage.Subject = "Sending an e-mail from a web page"
    mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
    
    ' TODO: Set the mailMessage.Body property
    mailMessage.Body = Message
    
    System.Web.Mail.SmtpMail.SmtpServer = "localhost"
    System.Web.Mail.SmtpMail.Send(mailMessage)
    
    SendMail = "Your message was sent to " & mailMessage.To
    
    End Function

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            Your email address: 
            <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
        </p>
        <p>
            Your message: 
            <asp:TextBox id="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox>
        </p>
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Send"></asp:Button>
        </p>
        <p>
            <asp:Label id="Label1" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>

           
       
Related examples in the same category
1.Simplest Way of Sending Email from Gmail
2.Send out email in code behind (C#)
3.Send out an Email
4.Send email with attached file
5.Send email out through asp:form
6.Send email to all employees in database
7.Send email with html form message
8.Email message in a html format
9.Email form with cc and bcc
10.Email with priority
11.Send email function
12.Email with pictures
13.Email with attachment
14.Send email with more than one attachments
15.Send out an email in case of page error
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.