0

can anyone see why this wont send...ive checked email address and password numerous times...

Imports System.Net.Mail

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 Dim Mail As New MailMessage
    Mail.From = New MailAddress("myemail@googlemail.com")
    Mail.To.Add("myemail@googlemail.comm")
    Mail.Subject = "test"
    Mail.Body = txtcomment.Text
    Dim smtp As New SmtpClient("smtp.gmail.com")
    smtp.Port = 587
    smtp.EnableSsl = True
    smtp.Credentials = New System.Net.NetworkCredential("myemail@googlemail.com", "mypassowrd")
    smtp.Send(Mail)
    lblconfirm.Text = "Sent Successfully"
 Catch ex As Exception 
        lblconfirm.Text = "There was an error"
    End Try


End Sub
user1055487
  • 261
  • 4
  • 8
  • 24

3 Answers3

0

A few thoughts:

  • First, what is the error message you're seeing? The Exception type, message and stack trace can tell you a lot about what's going on.
  • Second, have a look at this possibly related posting. The order in which you configure the SMTP client's properties can matter.
Community
  • 1
  • 1
mtutty
  • 815
  • 2
  • 10
  • 22
0

Are you actually receiving any error? An error message would be very helpful.

If you aren't getting any error message, there are a few things to consider.

  1. Gmail may be interpreting your requests to send mail as spam/malicious. Many large email providers have measures in place to prevent people abusing their smtp servers.
  2. Your spam filter may be intercepting the emails you are trying to send, especially since you are sending them to yourself. We have seen this more than once when developing apps. Email may look like it isn't working, but in fact the emails are just trapped by a spam filter.

Hope some of this helps.

SouthShoreAK
  • 4,176
  • 2
  • 26
  • 48
0

We need to get error message to know what's the issue. However, please check after adding this line:

smtp.UseDefaultCredentials = false;
Ashwini Verma
  • 7,477
  • 6
  • 36
  • 56