LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a mail message from LV2012

I am trying to send a mail message to a GMail a/c. 

 

Got this example from NI website. But keep getting a .Net error that is very cryptic to say the least - it complains about some Null arguments. ( Got the Server and Port from my working mail client on iPhone) 

 

I seldom work with LV Reference nodes and so not sure if the way i wired the "new reference" is correct.  So what am i doing wrong ??

SMTP_Mail From LV2012.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 8
(3,357 Views)

@MogaRaghu wrote:

I am trying to send a mail message to a GMail a/c. 

 

Got this example from NI website. But keep getting a .Net error that is very cryptic to say the least - it complains about some Null arguments. ( Got the Server and Port from my working mail client on iPhone) 

 

I seldom work with LV Reference nodes and so not sure if the way i wired the "new reference" is correct.  So what am i doing wrong ??

SMTP_Mail From LV2012.png


I assume NetworkCredential or MailMessage return an error. That would also cause there reference to be null. Their errors might be more descriptive.

 

Where does MailMessage come from? It probably needs to be created with a constructor. "new reference" will be null by default, and that won't work.

 

Note that both of those references (NetworkCredential and MailMessage) need to be closed. That can be done right after setting them in the SmtpClient (your closing the reference, not the object), or after closing the SmtpClient if that's more convenient. But they need to be closed (unless they are null obviously), or you will leak memory.

0 Kudos
Message 2 of 8
(3,327 Views)

what server name and port are you using?

 

also, have you configured to allow connection from insecure sources?

im quite sure, you cannot use SMTP or IMAP if this is not enabled.

 

regards

 

PS: the snippet is nice, and would be code normally, except the board does mess that up. please don't forget to also attach the snippet as a file to your posts.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 3 of 8
(3,323 Views)

@jwscs

 

i have now attached the snippet as a file. 

 

The server is    Gmail SMTP server  

The port is 465. 

 

The above settings copied from my iPhone. But somehow i have a feeling that i am missing in the  newReference ... I don't think i am constructing it or creating it proper. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 8
(3,314 Views)

send-email--LV2016.png

 

tested and it works


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Download All
0 Kudos
Message 5 of 8
(3,304 Views)

@jwscs

 

Wow ...looking at the code in LV 2016 looks so simple. However for some specific reasons i am sticking around with LV2012 and the example which you had sent for LV2012 opened fully broken. All the SubVIs are missing - maybe a LLB would have been better ? Could you please help resolve this ? Thanks 

Snippet.PNG

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 8
(3,277 Views)

sorry for that, i thought this might happen even when backsaved.

the backsaved vi opened for me in lv2016, but it seems the vis are newer than 2012.

 

use the search in the functions pallette (right mouse on block diagram -> search -> smtp)

it seems there are "real" vis for smtp http://zone.ni.com/reference/de-XX/help/371361J-0113/lvcomm/email_vis/

 

and be aware, that using TLS you will need a different port, presumably something that can STARTTLS, as for SSL

 

regards

 

EDIT: from gmail help

smtp.gmail.com on port 465, if you’re using SSL. (Connect on port 587 if you’re using TLS.)

EDIT2: and like wiebe said, check the "new reference" for the "Mail Message", that looks wrong

EDIT3: have a look at this https://forums.ni.com/t5/Example-Programs/Sending-SMTP-Email-Attachments-from-LabVIEW/ta-p/3509209

EDIT4: also you might want to post the error you get, might be that there is an explicit statement of the smtp server inside


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 8
(3,269 Views)

I saw an example in the LV2012 help section. Shown below .... wonder what kind of a Mail server will this work with ? Where does one enter username and password ?  Anyone ever try this out ??

 

Email Notification.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 8
(3,240 Views)