Showing results for 
Search instead for 
Did you mean: 

[ERROR] Sending email on labview (Gmail)

Go to solution

I'm trying to send email via this program ( as attached ) with gmail, i tried using 2 ports ( port 485 and port 587 ) and both showed me errors.

Port 485 's error shows : System.Net.Sockets.SocketException

Port 587 's error shows : System.Net.Mail.SmtpException

i have also attached screenshot of both errors below.

Any help is greatly appreciated !

*I'm using NI LabVIEW 2013 SP1 (32-bit)

0 Kudos
Message 1 of 22

Unfortunately I am on 2012 so I can't actually see your code, but from the errors it seems that your connection is not working properly, do you have SSL enabled in your connection setup?


Port 587 is the accepted port for gmail using SSL, 485 has been discontinued to the best of my knowledge as all email access for Gmail now needs to go through SSL communications. 


Just in case you want to test with another email sending program that definitely works I have attached the version of Gmail email code that I used successfully last week. The SMTP settings etc are all correct you will just need to fill out the email user details.

0 Kudos
Message 2 of 22

Hi ogk,

thanks for the reply,

I tried using your program but there's an error showing :

 Invoke Node Error calling method System.Net.Mail.SmtpClient.Send, (System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at) <append><b>System.Net.Mail.SmtpException</b> in

Is it possible that there's problem with my network connections? As i'm currently using my school's computer connected directly to my phone's personal hotspot

Edit : When i opened the program it says that .NET assembly changed ( attached screenshot )

0 Kudos
Message 3 of 22
Accepted by topic author stud789

Found out what was the problem....the gmail account has to change the security settings to allow 3rd party device to log in.

Problem solved!

Message 4 of 22

That's excellent you found a fix for this, I'm having similar issues. 


Where did you find the security settings that needed to be adjusted? 


Thanks in advance!





0 Kudos
Message 5 of 22

Here is where you allow "less secure apps"

Message 6 of 22

I also am having difficulty using this.  The error message that I get is:


Invoke Node Error calling method System.Net.Mail.SmtpClient.Send, (System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    Inner Exception: System.Net.Mail.SmtpException: Failure sending mail.
    Inner Exception: System.Net.WebException: Unable to connect to the remote server
    Inner Exception: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it <append><b>System.Net.Sockets.SocketException</b> in


I have allow less secure apps in Gmail set to on.


LV 2020
0 Kudos
Message 7 of 22

I just tested the sample VI and it works fine when I changed "Turn on less secure apps".


I turned it off and immediately got the same error you reported.

Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 8 of 22

I remember having difficulties with this. Here is a screenshot of how I'm using the LabVIEWSMTPClient.lvlib. You must wire a True constant to "use TLS" Hope this helps!

Message 9 of 22

Same problem with me...

I asked the IT service (university proxy) and ports 465 and 587 are open.

I turned on the option in the gmail account for less secure device.

I don't understand where is the problem... both my code and the example posted here before give me the same error.



If you have any idea...







0 Kudos
Message 10 of 22