From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[ERROR] Sending email on labview (Gmail)

Solved!
Go to solution

Hi,
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
(12,456 Views)

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
(12,438 Views)

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 Email.vi

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
(12,429 Views)
Solution
Accepted by 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
(12,387 Views)

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!

 

 

 

Winston

0 Kudos
Message 5 of 22
(12,220 Views)

Here is where you allow "less secure apps"

https://www.google.com/settings/u/0/security/lesssecureapps

Message 6 of 22
(11,808 Views)

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 74.125.70.108:587) <append><b>System.Net.Sockets.SocketException</b> in Email.vi

 

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

Jim

LV 2020
0 Kudos
Message 7 of 22
(10,707 Views)

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

 

https://www.google.com/settings/u/0/security/lesssecureapps

 

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
(10,698 Views)

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
(10,696 Views)

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.

Untitled.pngUntitled2.png

 

If you have any idea...

 

thanks

 

regards,

 

Hicham

0 Kudos
Message 10 of 22
(9,552 Views)