Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a code in VB.NET to send email from my gmail account. For many years it was working fine, now our office space has shifted to another location and the code has stopped working.

It throws "server does not support secure connection" error.

I tried to put EnableSsl = False, but it throws another error.

I have already checked less secure app settings in gmail. It's fine.

I have tried telnet for gmail account here, that's also working.

I am not able to understand the problem and hence not able to resolve it.

Kindly help!

What I have tried:

VB
SmtpServer.Credentials = New Net.NetworkCredential("xxx@gmail.com", "xxx")
            SmtpServer.Host = "smtp.gmail.com"
            SmtpServer.Port = 587
            SmtpServer.EnableSsl = True
            SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network
            SmtpServer.UseDefaultCredentials = False
Posted
Updated 1-Jan-20 20:13pm
v3
Comments
RickZeeland 1-Jan-20 3:30am    
What version of the .NET framework are you using?
It might have to do with an old version that does not support the new SSL standards.
Member 10128787 1-Jan-20 4:13am    
C:\Users\Lenovo>wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version
Version
4.5.50932
4.5.51209
10.0.30319
2.0.50217.0
3.0.40218.0
4.6.01055
4.1.41102.0
4.5.50710
13.0.0.99
14.1.11106.0
4.5.50932
4.5.21005
1.0.10609.0
4.1.41102.0
2.0.50217.0
4.5.21005
3.11.50727
5.2.30624.0
4.6.00081
2.0.20525.0
4.6.00081
4.0.30319
2.0.3010.0
4.5.51651
4.6.01055
4.6.00127
1.0.23224
4.5.51641
4.6.01055
Richard MacCutchan 1-Jan-20 5:39am    
The issue seems to be that the gmail server does not like something about either your account, or the content of the message. I have just tried a similar test and gmail stopped it because it failed the security tests (which is correct). You should try the Google help forums, as it may well be nothing to do with your actual code.
Richard MacCutchan 2-Jan-20 3:49am    
You have updated your question but not added any more information. Please show the complete code for the mail sender, including the part that produces the exception.

1 solution

Your port and suchlike look OK, so it's probably that GMail doesn't "trust" your app.
Have a look here: Less secure apps & your Google Account - Google Account Help[^] and change the security level.
 
Share this answer
 
Comments
Member 10128787 1-Jan-20 4:05am    
Thanks for the reply!

Actually I have already checked my gmail settings for less secure apps. It's fine. Secondly, if gmail was an issue it shouldn't have worked at another location also.

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