Dim emailTo As String = TxtEmail.Text.Trim() If emailTo.Length > 10 Then Try Dim Smtp_Server As New SmtpClient Dim e_mail As New MailMessage() Smtp_Server.UseDefaultCredentials = False Smtp_Server.Credentials = New Net.NetworkCredential("myemail@gmail.com", "***16-digit-code***") Smtp_Server.Port = 587 Smtp_Server.EnableSsl = True Smtp_Server.Host = "smtp.gmail.com" e_mail = New MailMessage() e_mail.From = New MailAddress("myemailaddress@gmail.com") e_mail.To.Add(emailTo) e_mail.Subject = "Login OTP" e_mail.IsBodyHtml = False e_mail.Body = "some text here" Smtp_Server.Send(e_mail) MessageBox.Show("Your login OTP has been sent to " & emailTo) LblOTPSuccess.Visible = True TxtOTP.Visible = True BtnVerifyOTP.Visible = True TxtOTP.Focus() Catch error_t As Exception MessageBox.Show(error_t.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Else MessageBox.Show("Email address is invalid or too short", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error) End If
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter