A user have to register to the site using Her existing email address as a user name so I need to send an email to the user's email address once her registration to my site is successful can anyone provide me with a code ASAP please

Hi

Try this code

Try
    '(1) Create the MailMessage instance
    Dim mm As New MailMessage(FromEmailAddress, ToEmailAddress)

    '(2) Assign the MailMessage's properties
    mm.Subject = "Test Email... "
    mm.Body = "This is a test message..."
    mm.IsBodyHtml = False

    '(3) Create the SmtpClient object
    Dim smtp As New SmtpClient

    'Set the SMTP settings...
    smtp.Host = Hostname.Text
    If Not String.IsNullOrEmpty(Port.Text) Then
        smtp.Port = Convert.ToInt32(Port.Text)
    End If

    If Not String.IsNullOrEmpty(Username.Text) Then
        smtp.Credentials = New NetworkCredential(Username.Text, Password.Text)
    End If

    '(4) Send the MailMessage (will use the Web.config settings)
    smtp.Send(mm)

    'Display a client-side popup, explaining that the email has been sent
    ClientScript.RegisterStartupScript(Me.GetType(), "HiMom!", String.Format("alert('An test email has successfully been sent to {0}');", ToAddress.Replace("'", "\'")), True)

Catch smtpEx As SmtpException
    'A problem occurred when sending the email message
    ClientScript.RegisterStartupScript(Me.GetType(), "OhCrap", String.Format("alert('There was a problem in sending the email: {0}');", smtpEx.Message.Replace("'", "\'")), True)

Catch generalEx As Exception
    'Some other problem occurred
    ClientScript.RegisterStartupScript(Me.GetType(), "OhCrap", String.Format("alert('There was a general problem: {0}');", generalEx.Message.Replace("'", "\'")), True)
End Try

Mark as solve if it helps you

Thanx a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.