# Email reader metadata configuration

**URL:** <https://forum.cloverdx.com/t/email-reader-metadata-configuration/919>\
**Category:** CloverDX Platform\
**Created:** [August 31, 2011, 12:00am UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919 "2011-08-31T00:00:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranusuri](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranusuri](https://forum.cloverdx.com/u/ranusuri)\
**Post date:** [August 31, 2011, 12:00am UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/1 "2011-08-31T00:00:00Z")

</div>

Hi,  
I am new to Clover ETL. Have downloaded the ETL designer for fedora linux and installed it.  
I need to setup a Email reader, read the attachments (CSV or XML) and write it to specified folder location.

I have setup the email properties for the reader (IMAP, server host, username and password) in the graph

Questions -  
1. Help files do not mention any information on the field mappings to use. What should I be using in that field  
2. How do I setup the metadata information for the edge output connection to view the data.

Also, I am seeing the following error in the log when Email reader was setup with JDK 1.6  
Exception in thread “Thread-7” java.lang.NoClassDefFoundError: javax/mail/NoSuchProviderException  
at java.lang.Class.forName0(Native Method)  
at java.lang.Class.forName(Class.java:247)  
at org.jetel.component.ComponentFactory.getComponentClass(ComponentFactory.java:104)

Please help me out.

Thank you  
Ram

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [September 1, 2011, 10:16am UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/2 "2011-09-01T10:16:13Z")

</div>

Hello Ram,  
_mapping_ attribute defines a mapping between standard and user defined mail parts and clover fields.  
Please see the attached graph. It illustrates 3 ways of getting the attachment files (each phase corresponds to one way):

- Connect the attachment (1st) port but you don’t need to map anything to this output → all attachments are saved in _tempURL_ directory (_data-tmp_ of current project by default) with unique names

- Map _FileName_ and _AttachmentRaw_ to attachment port and configure [Writer](http://www.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/datawriter.html) to write the _AttachmentRaw_ field to the file whose name depends on _FileName_ field (see [Partitioning Output into Different Output Files](http://www.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/partitioning-output-into-different-output-files.html)) → all attachments are saved in _tempURL_ directory (_data-tmp_ of current project by default) with unique names and in the files with the original name from the e-mail

- Map _FileName_ and _AttachmentFile_ to attachment port and rename the files with [SystemExecute](http://www.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/sysexecute.html) - → attachments are stored only under the original names. **Note** that because of a minor bug ([https://bug.javlin.eu/browse/CLD-2840](https://bug.javlin.eu/browse/CLD-2840)), you need to add the user field _AttachmentFile_ and map it into your clover _AttachmentFile_ file.

The error suggests that you miss _mail.jar_ in your CloverETL Designer. Please check the folder _\<path\_to\_designer\_home\_directory\>/plugins/com.cloveretl.gui.commercial\_3.X.X/lib/plugins/org.jetel.component.commercial/lib_ if it contains _mail-1.4.2.jar_ file.

- [EmailReader.grf](https://cdn.cloverdx.com/forum/417%5F247528503a95860d3fcb6df48ba81697/EmailReader.grf)

---

<div class="post-metadata">

**Author:** ![ranusuri](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranusuri](https://forum.cloverdx.com/u/ranusuri)\
**Post date:** [September 1, 2011, 9:09pm UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/3 "2011-09-01T21:09:01Z")

</div>

Thank you Agata Vackova.

Your example EmailReader graph helped me a lot.

I had to spend couple of hours before I could get it working.  
Issues encountered -  
1. The charset for the attachment. I left the default charset instead of UTF-16. Realized after a long time.  
2. My email attachment was a single column csv file. The default delimiter ‘\n’ was not working. Always threw error that the SimpleDataParser could not read raw data. Had to change it to EOF delimiter.

Regarding the mail exception -  
mail-1.4.2.jar is available in the \<path\_to\_designer\_home\_directory\>/plugins/com.cloveretl.gui.commercial\_3.1.0/lib/plugins/org.jetel.component.commercial/lib/  
I believe it has something to do with my jdk and the library path.  
I am using Fedora 14 and it has inbuilt open-jdk jre 1.6 installed. Not sure if I have to configure anything different for that.  
I also tried using JDK as

./clover-designer -vm /opt/jdk1.6.0\_26/bin/java

but same issue.

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [September 2, 2011, 7:27am UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/4 "2011-09-02T07:27:12Z")

</div>

Hello Ram,  
I do not really see the relationship between the delimiter and reading the attachments with EmailReader. But if you want to treat the EOF as delimiter, you can set the attribute _aeofAsDelimiter_ to _true_ value in the last field of your metadata (see [Details Pane](http://www.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/details-pane.html) for more information).  
I’m also a bit confused with the error you get: Does the graph run successfully, but the log contains the error message? Could you send the full error stack trace?

---

<div class="post-metadata">

**Author:** ![ranusuri](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranusuri](https://forum.cloverdx.com/u/ranusuri)\
**Post date:** [September 2, 2011, 2:02pm UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/5 "2011-09-02T14:02:45Z")

</div>

Hi Agata,

I am sorry. Will be more specific.  
The issue with email reader problem was the use of default charset instead of UTF-16. After I read the email attachment, I am feeding the attachment file (which is a single column csv) as input to a Universal Data reader.  
File URL - port:$0.AttachmentRaw:discrete

From the Universal Data reader, I am reading the csv and writing it to a DBOutputTable. When I open the csv file using vi command, it opens up good with the data. The edge metadata between the universal data reader and dboutput table has one field with delimiter as ‘\r\n’. When I view the data in grid format or when I run the graph, I see the below parser error.

Node DATA\_READER0 finished with status: ERROR caused by: Parsing error: Unexpected record delimiter, probably record has too few fields. in field # 1 of record # 1, value: '001070457  
’  
Attached the sample csv file used.

To fix it, I had to remove the delimiter and use EOF delim as true. This way I could read the fields in the file and insert into the db table. The field contained special characters at the end but I was able to trim them and insert into the column

Regarding the mail.jar error for class not found -  
My classpath environment was incorrect. I fixed it and started to work. Thank you

- [temp.csv](https://cdn.cloverdx.com/forum/13678%5F3430f760fbb223daa82b7044bd868eed/temp.csv)

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [September 5, 2011, 12:49pm UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/6 "2011-09-05T12:49:00Z")

</div>

Hello,  
all you need is to set proper charset in DataReader - UTF-16LE. Please see the attached file: both DataReaders (when reading the data directly from file, as well as parsing it as attachment) have the exactly same configuration.

- [EmailReader1.grf](https://cdn.cloverdx.com/forum/417%5F63aaa0447323f02dfaa3dfebedaca17c/EmailReader1.grf)

---

<div class="post-metadata">

**Author:** ![ranusuri](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranusuri](https://forum.cloverdx.com/u/ranusuri)\
**Post date:** [September 8, 2011, 7:14am UTC](https://forum.cloverdx.com/t/email-reader-metadata-configuration/919/7 "2011-09-08T07:14:10Z")

</div>

Thank you Agata
