Sending Mail with ASP 2
27 August 2008 Tips  Marek Sienkiewicz
Bubble
Place three labels and three text boxes on your contact page. Name them lblName, lblEmail, lblMessage, txtName, txtEmail, txtMessage. Make sure that you select multi-line for the txtMessage. Place a button and name it btnSubmit.
 
In your web config file add the following:
 
<system.net>
<mailSettings>
<smtp from =" you @yourdomainname">
<network
            host = "mail.yourdomainname"
            port= "25"
            userName ="username"
            password ="password" />
</smtp>
</mailSettings>
</system.net>
 
In your code behind page contact.aspx.vb add the following under the btnSubmit_Click event:
 
Dim mm As New Net.mail.MailMessage(txtEmail.Text, ToAddrress)
 
mm.Body = txtName.Text + vbNewLine + txtEmail.Text + vbNewLine
+ txtMessage.Text
 
mmIsBodyHtml = False
 
Dim smtp As New Net.Mail.SmtpClient
 
smtp.Send(mm)
 
 
 





Please post your comments:

Name

Email
                           

   

Enter the text you see in the box:

Captcha Image