Hi everyone.
I followed an Email tutorial on this link:
https://www.tutorialspoint.com/vb.ne...send_email.htm
The purpose for sending email is when user wants to reset password. A new password is sent to their email.
1st Question:Code:Private Sub FgtPW_LinkLabel_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles FgtPW_LinkLabel.LinkClicked If MessageBox.Show("Are you sure you want to reset password?" & vbNewLine & vbNewLine & "A new password will be sent to the following email:" & vbNewLine & vbNewLine & vbTab & My.Settings.Email, "Forgot Password", MessageBoxButtons.YesNo, MessageBoxIcon.Question) _ = DialogResult.Yes Then Try Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() SmtpServer.UseDefaultCredentials = False SmtpServer.Credentials = New Net.NetworkCredential(My.Settings.Email.ToString, "password") SmtpServer.Port = 587 SmtpServer.EnableSsl = True SmtpServer.Host = "smtp.gmail.com" mail = New MailMessage() mail.From = New MailAddress("[email protected]") mail.To.Add(My.Settings.Email.ToString) mail.Subject = "EVC Kiosk New Generated Password" mail.Body = "This is for testing SMTP mail from GMAIL" SmtpServer.Send(mail) MsgBox("mail send") Catch ex As Exception MsgBox(ex.ToString) End Try End If End Sub
I was flashed with the error upon testing. Something about SMTP server requires a secure connection or the client was not authenticated.
Can anybody tell me what this means?
2nd Question:
Do I really need an email password here? I mean there is no way I will know the email password the user will have. When we send email to others, we are not asked for their password right? Also, what if the user changes email with different password.Code:SmtpServer.Credentials = New Net.NetworkCredential(My.Settings.Email.ToString, "password")
I don't understand the reason behind this line of code. Can anyone enlighten me?




Reply With Quote
