I have issue with my code,
what i receive as error is :
System.ArgumentException: 'Argument 'Prompt' cannot be converted to type 'String'.'
and it's always shows
Catch ex As System.Exception
MsgBox(ex, MsgBoxStyle.Critical)
End Try
i have try to add in my google account insecure app is turned on, but still cannot send the email.
what i receive as error is :
System.ArgumentException: 'Argument 'Prompt' cannot be converted to type 'String'.'
and it's always shows
Catch ex As System.Exception
MsgBox(ex, MsgBoxStyle.Critical)
End Try
i have try to add in my google account insecure app is turned on, but still cannot send the email.
VB.NET:
Private Sub SendEmailGmail()
Try
Dim SMTP_Server As New SmtpClient
Dim Mail As New MailMessage
SMTP_Server.UseDefaultCredentials = False
SMTP_Server.Credentials = New Net.NetworkCredential(txtUserAcc.Text, txtUserPass.Text)
SMTP_Server.Host = "smtp.gmail.com"
SMTP_Server.Port = 587 'Check Port
SMTP_Server.EnableSsl = True
Mail = New MailMessage()
Mail.From = New MailAddress(txtFrom.Text)
Mail.To.Add(txtTo.Text)
Mail.CC.Add(txtCC.Text)
Mail.IsBodyHtml = True
Mail.Priority = MailPriority.Normal
Mail.BodyEncoding = System.Text.Encoding.UTF8
Mail.SubjectEncoding = System.Text.Encoding.UTF8
Mail.Subject = txtBody.Text
Mail.Body = txtBody.Text
If Guna2DataGridView1.Rows.Count > 0 Then
For Each row As DataGridViewRow In Guna2DataGridView1.Rows
If row.Cells("Path").Value IsNot Nothing Then
Dim MsgAttach As New Attachment(row.Cells("Path").Value)
Mail.Attachments.Add(MsgAttach)
End If
Next
End If
SMTP_Server.Send(Mail)
MsgBox("Email was Sended", MsgBoxStyle.Information)
Catch ex As System.Exception
MsgBox(ex, MsgBoxStyle.Critical)
End Try
End Sub