04-05-2018 12:17 AM
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 ??
04-05-2018 03:53 AM
@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 ??
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.
04-05-2018 03:57 AM - edited 04-05-2018 03:59 AM
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.
04-05-2018 04:06 AM
@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.
04-05-2018 04:17 AM - edited 04-05-2018 04:18 AM
tested and it works
04-05-2018 05:43 AM
@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
04-05-2018 06:30 AM - edited 04-05-2018 06:42 AM
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
04-06-2018 11:00 AM
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 ??