Friday, June 22, 2012

Sending Mail from your domain name server

Imports System.Net
Imports System.Net.Mail
Imports System.Web
Imports System.IO
Partial Class contact
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        SmtpServer.Credentials = New Net.NetworkCredential("username", "password")
        SmtpServer.Port = 25
        SmtpServer.Host = "mail.xyz.in"
        mail = New MailMessage()
        mail.From = New MailAddress("info@xyz.in")
        mail.To.Add("emailaddress for send to")
        mail.Subject = "From Aspirant"
        mail.IsBodyHtml = True
        Dim st As String = "Name : " + TextBox1.Text + Environment.NewLine + " Email : " + txtemail.Text + Environment.NewLine + " Query : " + TextBox2.Text
        mail.Body = st
        SmtpServer.Send(mail)
           End Sub
End Class