Example Code

Gmail using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

Overview

Send an email using Simple Mail Trasfer Protocol (SMTP) to sync up with Gmail. LabVIEW still does not interact with email servers that need authentication, but the System.SmtpClient Class does interact with open email accounts.

 

 

Description

This VI uses SMTP property nodes in order to write a standard email and send it via a Gmail account.

 

 

Steps to Implement of Execute

Prior to running the code type in all the necessary information.

  1. Leave the Outgoing Mail Server (SMTP) as the default name (smtp.gmail.com)
  2. Add your Gmail Account User ID and Password (FYI: The password is not securely typed and can be accessed in a normal text display from the VI)
  3. Enable SSL (This will send the information securely over the internet)
  4. Sender's Email Address: the email address the email is coming from, Gmail Account
  5. Sender's Name: the name you wish to display as the sender's name in the "from" tag on the receiving email.
  6. Recipient's Email Address: the email address of the person who should receive the email.
  7. Recipient's Name: the name you wish to display as the "to" tag on the receiving email.
  8. CC- Optional: If you would like to add an additional receiver or send a copy to yourself add that email address in the CC String
  9. Subject and Body: Work just like a normal email add your desired text of the email.
  10. Attachment- Optional: This is optional but allows you to attach any file to the email

Once the email is created push the Run Arrow in order to send the email.

 

Note: If you receive Error -1172 with this example, try logging into the Gmail account with your browser.  This error can occur with Gmail accounts that have been inactive for a period of time.  You must log in with a browser and verify CAPTCHA text to reactivate the account.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Additional Information or References

Block Diagram

BD.PNG

 

Front Panel

FP.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
fvillasb
Member
Member
on

Thank you! It is the only VI that really works!

omarbedair
Member
Member
on

Very helpful. Now we can take it from there

AlexCV
Member
Member
on

8 years later and here I'm saying thak you. It's been very hepful to me.

havevun
Member
Member
on

Hello,

I used this VI on windows 7 and it works, but It did not work on windows 10.

These are the error code.

constructore note: Node not supported in current target.

Wire: type not supported in current target

The wire color is Green.

Please advise.

Thanks.

PHacke
Member
Member
on

Worked for me using Port 587, TLS enabled, and usage of "less secure app access" setting ON in gmail account security settings with LabVIEW's example vi "Send Email using SMTP Client.vi"

PMN1966
Member
Member
on

Has anyone had succes using TLS 1.2 on outlook.office365.com ?