This is really frustrating! I need to send emails from my visual basic.net 2008 project. I've gone through all of the google hits, and one strange thing got me. Why was every way of doing it different, and more, why didn't any of them work?
This code will run, and attempt to send the email but comes back failed.
So I changed it to:
And now the message box comes back with "Failure sending message" Which is really helpful! .... lol!
How do I fix this? Its got to be an authentication problem, but I'm not sure how to address that. All the other samples I have worked with don't get past using smtp, IE the program wont run, errors...bang, boom...whats smtp it asks. This program runs, and tries! YAY!
Thanks for the assistance. And for reading this question...again... probably for the 100th time.
Nick
Hello World!
The Home of Why Not?
This code will run, and attempt to send the email but comes back failed.
VB.NET:
Dim Message As New MailMessage("njdubois@gmail.com", "njdubois@gmail.com", "A PROGRAM SENT EMAIL", "Does it work")
Try
Dim Smtp As New SmtpClient("smtp.google.com", 587)
Smtp.Send(Message)
MsgBox("Message was succesfully sent ")
Catch ex As Exception
MsgBox("Message Fail!")
End Try
So I changed it to:
VB.NET:
Dim Message As New MailMessage("njdubois@gmail.com", "njdubois@gmail.com", "A PROGRAM SENT EMAIL", "Does it work")
Try
Dim Smtp As New SmtpClient("smtp.google.com", 587)
With Smtp
.Credentials = New Net.NetworkCredential(user, pass) ' USER and PASS are set to my gmail account.
.UseDefaultCredentials = False
End With
Smtp.Send(Message)
MsgBox("Message was succesfully sent ")
Catch ex As Exception
MsgBox(ex.Message)
End Try
And now the message box comes back with "Failure sending message" Which is really helpful! .... lol!
How do I fix this? Its got to be an authentication problem, but I'm not sure how to address that. All the other samples I have worked with don't get past using smtp, IE the program wont run, errors...bang, boom...whats smtp it asks. This program runs, and tries! YAY!
Thanks for the assistance. And for reading this question...again... probably for the 100th time.
Nick
Hello World!
The Home of Why Not?