Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
showing Error "Failure sending mail." please help me
i used port 587 because maximum example 587 used this port
how i can know the my mail port or it is right


error in this line
SMTP.Send(Mail)


massage is:- Just
"Failure sending mail."


What I have tried:

Imports System.Net.Mail

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Mail As New MailMessage
        Mail.Subject = "test email"
        Mail.To.Add("abcd@gmail.com")
        Mail.From = New MailAddress("abcd@gmail.com")
        Mail.Body = "test mail test mail 123456789 hi"
        Dim SMTP As New SmtpClient("smtp.gmail.com")
        SMTP.EnableSsl = True
        SMTP.Credentials = New System.Net.NetworkCredential("abcd@gmail.com", "***********************")
        SMTP.Port = 587
        SMTP.Send(Mail)
    End Sub
End Class
Posted
Comments
Richard MacCutchan 9-Oct-18 4:18am    
Google is not the best client to use for sending mail from applications. You should try your own SMTP provider.
MadMyche 9-Oct-18 9:22am    
Common problem using gmail is a security setting within the account; "Let Less Secure Apps Access Your Account". If this is turned off, you won't be sending email with this script, or just about any other SMTP client

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900