LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get email and plot attachment

I am using LV8.0.  I have a machine that spits out a periodic email with text in the body and a .csv file attachment.  I need to get the email, parse the body, and plot the .csv data and mark or delete the email to prevent duplication.  I have looked at the pop3 VIs but the attachment is in line and encoded.  Is there a way to get the decoded email from a client so that the spreadsheet can be plotted?  Or, can it be decoded within Labview or CVI?
Message 1 of 14
(5,522 Views)

Can you tell where you got the POP3 VI's?  What do you mean by "attachment is in line and decoded"?  In line with what?  Is the attachment MIME encoded?

Look on the web for a program called Munpack.  It is a DOS based program that will unpack MIME encoded files.  That may work for you.  There may be other freeware/shareware out there that could to the job as well.

I searched the forums for MIME decode and found this link which points to an OpenG library.  If there are VI's in the library that due MIME decoding, they should be much easier to incorporate into your VI's then an external DOS based or other 3rd party software.

0 Kudos
Message 2 of 14
(5,508 Views)
I got the pop vis from here: http://sine.ni.com/devzone/cda/epd/p/id/1373
What I meant was when I look at a retrieved email the body is html and the attachement (which is in line not separate) is encoded (mime, base64?).  I will take a look at your link to see if one of those vis does the decoding. 
Thanks
0 Kudos
Message 3 of 14
(5,490 Views)
I downloaded and tried the ogicpop vi and it does the same thing.  It displays the encoded attachment in line with the body and does not detach, decode and save it.  It appears that OGIC_POP_SaveAttachments.vi is looking for a crlfcrlf and doesn't find it so it never enters the decoding and saving routine.   If I retrieve the same email using Thunderbird, the attachment can be detached as opened in Excel as expected.
0 Kudos
Message 4 of 14
(5,481 Views)
The problem is in the "OGIC_POP_ListMessages" VI. The "Match Pattern" function that's searching for the start of the message listing is based on looking for "OK+" followed by CRLF. With my comcast server that's not what the server returned. It returned something like "OK+ 3 messages (xxxxx)" where "xxxxx" was the total byte size. If you delete the Concatenate String function and just wire through the \r\n constant to the Match Pattern it should work. At least it did with me. See attached screenshot:




Message Edited by smercurio_fc on 02-22-2008 10:04 AM
0 Kudos
Message 5 of 14
(5,476 Views)
That part seemed to be working fine.  It listed and retrieved the email but then didn't see the attachment as a separte file and displayed it in-line with the body in encoded form.  No attachment was saved despite the checkbox being checked.
0 Kudos
Message 6 of 14
(5,465 Views)
What checkbox? There is no checkbox on the main VI of the OGIC Pop Client (OGIC_POP_PopClientMain):

0 Kudos
Message 7 of 14
(5,459 Views)
0 Kudos
Message 8 of 14
(5,455 Views)
Ah. Looks like you downloaded the "single package" library, and that contains a different (looks like newer) version of the POP library.

I downloaded that version and tried it with my Comcast POP account and it correctly downloaded and saved the attachments from the emails that had attachments. Perhaps the machine that's creating the emails at your end is not properly attaching/encoding the messages? Although that's not likely since you said Thunderbird was able to decode and extract the attachments.

You can do the following if you want someone here to help you figure it out:
  1. Go to the block diagram of "OGIC_POP_Main".
  2. Double-click on the "OGIC_POP_SaveAttachments" VI so that its front panel is open when you fetch the message(s).
  3. Run the top-level "OGIC_POP_Main" VI. This will populate the "OGIC_POP_SaveAttachments" VI with the message information.
  4. Go to the front panel of the "OGIC_POP_SaveAttachments" VI. From the Edit menu select "Make Current Values Default".
  5. Save the "OGIC_POP_SaveAttachments" VI and upload it here. Then, someone can run it and try to determine why it's not extracting the attachment(s).
P.S. Not sure what version of LabVIEW you're running. If you have 8.5, please keep in mind that not too many people have 8.5. So, if you have 8.5 try to upload an 8.2 version as well. (File -> Save for Previous Version or something like that).


Message Edited by smercurio_fc on 02-22-2008 05:18 PM
0 Kudos
Message 9 of 14
(5,444 Views)
Here is a copy of the save attacments as you requested.  I am using 8.0.
0 Kudos
Message 10 of 14
(5,360 Views)