Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Gmail using LabVIEW

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. For more information about SMTP check out this link.

 

 

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.**

Grant H.
National Instruments
LabVIEW Product Marketing Manager
Comments
Trusted Enthusiast
Trusted Enthusiast

the code is a bit messy but the function it brings is great !

thanks


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Active Participant wbadry
Active Participant

Nice Post G-Money. Very Helpful indeed

Waleed El-Badry MSc.,MCPD, ISTQB Certified Tester
Assistant Lecturer
Mechatronics Department
Faculty of Engineering
Misr University for Science & Technology



View Waleed El-Badry's profile on LinkedIn

Member M1014757
Member

Hi  G- Money ,

its very helpful

Member Branson
Member

wow, very helpful!

Member duyson
Member

Dear G-money. I am doing  a project about smart house. I want to use your project in alarming through sending a gmail automatically. How can I integrate your VI to my project. My project is measure temperature and auto alarm through email if the temperature is higher than 50(C). Please give me the advices.

Thank you very much and wish you a nice day!

Son

email: tongduysonth@yahoo.com

Member todd.davis
Member

Thanks for developing this.  I am trying to send this via my school's server and get the 1172 error.  I retried with my active gmail account and get the 1172 error as well.  What else could be the problem?

Thanks

Member Gregoiree
Member

Hello,

I'm working with Labview 7.0, .Net Framework 2.0 and Windows 2000 Professional.

I tried to do the equivalent .vi on my software but I had a class conflict betwenn NetworkCredential and SMTPClient.Credentials

May be some one has already fix my problem

Thanks

Member dannnyds2
Member

i would like to use this vi in my uni project if thats ok. its a VAD monitoring system, and in this case it will allow the person to save their readings and email it to a doctor. the main problem is that i'm having a .NET error, its 1172 but i tried logging into gmail and it still comes up. any ideas?

My error seems to be in the Mail Address block for the reciepiant

Dan

dannnyds@gmail.com

Member StudMuffin
Member

Does anyone know how to send Microsoft Outlook Task Requests through a VI?

Member effgee
Member

Thanks for this - can't wait to try it out.

But I can't miss a chance to jump on my hobby horse - images of code are sharper and smaller filesize when saved in PNG (or gif or tif) format; JPG is only intended for photos

Member FernandoL
Member

very good man!!!

si funciona ya habia probado los otros que hay por aca mismo y nada pero porfin salio.... Gracias.!!!

Best Regards.
Ing. Edgar Lojan
Member IPTN
Member

Awesome

Member SaidElshayeb
Member

Gr8 thanks

Lecturer
Machanical Power Department
Helwan University, Egypt
Member m.meadows
Member

Sorry if this is a basic question. Do you know if this vi works on the 2009 OS X version?

Trusted Enthusiast
Trusted Enthusiast

It doesn't work on Mac OS X because it uses .NET which is windows only.

Sorry


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Member m.meadows
Member

Ahh missed that. Thank you.

Brinoceros
NI Employee

Just a warning - According to the MSDN documentation for SmtpClient, any credentials supplied are sent in plain text.  This means your username and password are NOT secure if someone happens to be looking

Brian A.
National Instruments
Applications Engineer
Arturo_M._Gomez
NI Employee

Hey Eric ! how are you, it's been a long time no talking with you. It's a cool example, you save me a lot of programming hours this night LOL

Arturo Gómez | Applications Engineering
Certified LabVIEW Associated Developer

National Instruments Latin America
01-800-010-0793
ni.com/support
Active Participant Terry_ALE
Active Participant

Brinoceros, Doesn't SSL take care of encrypting the credentials?


Certified LabVIEW Architect, Certified Professional Instructor, LabVIEW FPGA expert
ALE Consultants
LabVIEW Programming (make LV more popular, read this)
Member Heckler511
Member

Sweet!  Thanks for the posting

Brinoceros
NI Employee

Terry - you're right, I missed that property being set.  The session does still start unencrypted, but SSL kicks in before the credentials are sent.

Brian A.
National Instruments
Applications Engineer
Member Delber1
Member

Hey I have been having some issues with this VI in LabView 8.0. I get an error with the smtp client node in the "from" field and LabView says there is a bad terminal or unwired connection. I have a trial version of LabView that can run Gmail86.vi and it runs perfectly fine, but I only have full version of LabView 8.0. Does anybody know how to fix this problem?

Member Rocio_
Member

Great VI. Thank you!

Member rick s.
Member

Very useful. Thanks for the great post!

Member amitlipman
Member

Hey Antoine,

Did you find a way to send emails through gmail using Mac? or email through any other server (using Mac)?

All the best,

Amit

Member Mr_J
Member

Thank you for this vi.

To well close the attached file after sent, just add the Dispose.

dispose.jpg

it could create problems if you want to delete one of the attachments you sent, in Labview but also if you try to delete it from Windows.

++

Member kenes_fusa
Member

great vi. thank you!

Member Hong.Zhang@agresearch.co.nz
Member

Hi Mr_j

Do you know how to receiving email by using Labview?

Thanks

G-Money
NI Employee

http://sine.ni.com/devzone/cda/epd/p/id/1373

Grant H.
National Instruments
LabVIEW Product Marketing Manager
Member Hong.Zhang@agresearch.co.nz
Member

Hi Grant

I have donwlanded the mailpop70. When run the Mail Browser.vi got error 56 at POP Read to DOT-CRLF.vi.  Please help me.  Thanks. Hong

error 56.jpg

Member Hong.Zhang@agresearch.co.nz
Member

Hi Grant

Your code was working very well for poet 25. But now I have to send email and SMS to port 465.

My setting are:

Mail server: send.xtra.co.nz

Port:465

SSL: on

User name: XXXXX

Passsword: ********

Those settings are working for outlook. But its dont work for your code now.

I have got error message.

Please help me to fix the problems.

Thanks

Hong

error 1172.jpg

Active Participant Miro_T
Active Participant

Hi,

Did you check "Possible reason(s)" paragraph in your screen shot?

Also, were there any changes to your .NET assembly ?

Member razso
Member

THANK A LOT!!

MAY GOD BLESS ON U!!

Member razso
Member

did u had solve this problem?

i also get this error after sending a few massage..

Member AdeLuna
Member

Hi!

I can't send anything ):

i really appreciate  if you could help me

when i'm using the VI an erreos appears me

is the 1172 error, i have no clue how to make it work

please help!

Member razso
Member

1. u need to log in your gmail account

2. go to setting acount

3.click forwarding and pop/imap

4.setting same as picture above...

5. save..

** u need to log in first your gmail account google web before send email using labview.. this labview gmail unable to send attachment..gmail setting.png

Member JamesXu
Member

Hi Grant:

     Thanks for your vi at first. When i running this vi, it almost occurs error 1172. I have logged in my email, but it has no effects. Anyone can help me? Thanks a lot.

3.bmp

Member Jepz
Member

For those who encountered error-1172.

In your gmail account, navigate to settings/security/lesssecureapps and Turn On Access for Less Secure Apps. You should be able to send email without signing in to Gmail.

Best regards,

Jep

Member HORSZI
Member

Hy!

It was great. The help with less secure app. I have a problem, In a running VI I have a continous sign. When it's high, send a lot of mail from "Send email", but I want to receive just one. I tried to solve this problem with loops, but it didn't work. Do you have an idea anybody? So I want to creat from a continous sign to one rising edge.

Thanks the help before!!

Szilárd

Member lf19902001Wahah
Member

Great VI. Thanks!

Thanks, Jepz! That's right solution for the Error -1172!

I found that if you use Outlook.com account, you won't have this problem. Does this mean Outlook.com use less secure sign-in technology compared with google ?

Member lf19902001Wahah
Member

Check Jepz's reply.

Member jrvinck
Member

did you find a soltion for your problem im getting the same error

Member lf19902001Wahah
Member

In your gmail account, navigate to settings/security/lesssecureapps and

Turn On Access for Less Secure Apps. You should be able to send email

without signing in to Gmail.

If you use Outlook.com account, you won't have this problem.

Member Easterly81
Member

Recently this VI stop working from me. I checked my gmail "settings/security/lesssecureapps".  Any reason this would stop functioning on all my machines?  I set up my gmail account in outlook on one of the machines  today and outlook send email out just fine. Any help would be appreciated.

labviewError.bmp

Member lf19902001Wahah
Member

>> I checked my gmail "settings/security/lesssecureapps"

Did you turn it on or off? The "Access for Less Secure Apps" option should

be turned on.

Member Easterly81
Member

Yes, the first thing I did was signed up for a new gmail account because the old gmail account that all the machines were using nobody knew the password. With the new Gmail account setup up with the less secure apps setting turned on still non of the machines send email.

I am using labview 8.0

Member lf19902001Wahah
Member

If you have turned on the less secure apps setting, I don't know what else

you can do to solve this problem. But this is strange, the program works

well on my computer. I use LabView 2013. OS: Win7.

Member lf19902001Wahah
Member

Maybe worth asking this question on Google's forum?

Member Easterly81
Member

I'm using windows 2000 with labview 8, could this be the problem?  I just tried using a outlook.com email account and ran into the same issue.  I even made a simple test VI and still no luck (i tried port 25 and 587)

emailTEST.bmp

Member jeasterly
Member

It work but not on my windows 2000 machines