Para descargar el software de NI, incluyendo los productos que se muestran a continuación, visite ni.com/downloads.
This example shows how to send email attachments from LabVIEW using any SMTP email service, such as Gmail.
This example is based off of a previous example, which enables you to send an email using Simple Mail Transfer Protocol (SMTP) to sync up with Gmail in LabVIEW. The code has been simplified and cleaned up in this example.
Steps to Implement or Execute Code
Note: If you receive Error -1172 with this example, you may have to change your e-mail account protection settings.
Additional Information or References
VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**
El código de ejemplo del Intercambio de Código en la Comunidad de NI está autorizado con la licencia MIT.
Hi Penata, thanks for your vi. I tried it but got error 1172 saying "No connection could be made because the target machine actively refused it 188.8.131.52:587". I'm using gmail to send emails and pretty sure that all the settings in the VI are correct. According to http://mail.google.com/support/bin/answer.py?answer=13287, I tried both 587 and 465 as the port, and nothing would help. 587 will give the 1172 error and 465 will hang the vi for a while after stopping it. This 1172 error is unlikely due to the suggestion from http://decibel.ni.com/content/docs/DOC-2401, "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." because the error kept on even when I login to my gmail account.
I got myself a solution from http://stackoverflow.com/questions/2737823/unable-to-send-smtp-mail-with-net-network-issue, which says to turn off the antivirus software. I turned off McAfee on my PC and it did work. Now, I'm able to send email, even when I log out my account. However, I'm not happy since I have to keep my antivirus off. My question is, is there any way to walk around this issue? i.e. being able to send email with antivirus on?
I'm having a similar problem -- this VI worked for me a few months ago (port 587) but now it's not (on either 587 or 465). Tried telnet as per this help screen from Google http://mail.google.com/support/bin/answer.py?hl=en&answer=78775 I can telnet to 465, but not 587. Using port 465, I get a -1172 error -- ".... the operation has timed out." I don't have the option of turning off the antivirus program; the corporate IT people quite appropritately don't allow that.... Ideas, anyone?
Thanks for the code.
I would like to add one point the code.
In AttachmentCollection, please do not forget to add "Dispose()" after emailing.
If not, the file handler of the attachment is not released from time to time (not reliable).
I think this is a bug because all resources should be released by closing the handler.
can you help me with this issue i have with my code?
but i am not able to figure it out where to put the dispose attachment.
i want to overwite a file and send it later, but is always used in the vi after i send it by email i cannot get to dispose it.
can you help me? i would really appreciate it
I am using nearly the same to send an HTML Mail with images included. But I am facing problems, when using Images with spaces in the filenames.
The HTML generated looks like this:
<HTML> <BODY> <IMG src="Filename with spaces.jpg"> </BODY> </HTML>
The file is added to the mail as an attachment, but is not shown in the mailbody. I did try to replace the spaces with %20 in the HTML string, then in Outlook the file is no longer shown as an attachment, but nevertheless there is no picture showing. Any Ideas? May be an example of adding the attachment via contentStream?
In the Snippet you see my workaround: I just copy the picture to a new file without spaces in the filename - then everything works as expected...
I tried using the VI as such with necessary details for our local network email, it throwed error -1172. so I changed the constant to false (disable ssl as it does not require user name and pwd) and it worked.
I think when you connect to server outside intranet you need the SSL, so if you use gmail or yahoo email etc.. you need to enable SSL(it is decided by th server settings).
Hope this helps people who look at this thread in the future!!
அனிஷ்பிரபு தி. |Anish Prabu T.
முதல் இந்திய ஆய்வுமெகபொப சிற்பி |First Indian CLA
சோதனைநிறுத்தம் சிற்பி |CTA
மற்ற சான்றிதழ்கள் |Other Certificates
யாதும் ஊரே! யாவரும் கேளிர்!! |World's Citizen ! Everyone is my kin!!