Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.

How to read Email Body in NiFi

avatar
Expert Contributor

Hello
How to read the body of the mail in nifi? I don't see any relevant processor for this.
I see there is an "ExtractEmailAttachments" processor but will it read body reliably? We tried to test and see that it is able to make two flowfiles after executing. One is with a text/plain and has the email body present and another one is text/html having some html content having what we sent in mail as well.
But due to its name being "ExtractEmailAttachment" and not something like ExtractEmailBody I am not sure.

How to effectively and reliably read the mail body? In NiFi 1.28 we had Python (which was able to read the body of mail) but in NiFi 2.8 we don't have Python and able to see GroovyScript which is not allowing import of javax.mail type libraries which is required for writing the logic to fetch the email body.

2 REPLIES 2

avatar
Master Collaborator

Hello @AlokKumar

Thanks for being part of our community. 

That what you need should be possible with the ExtractEmailAttachments. 
This processor extracts the parts based on a MIME format: 

Writes Attributes

Name Description
filenameThe filename of the attachment
email.attachment.parent.filenameThe filename of the parent FlowFile
email.attachment.parent.uuidThe UUID of the original FlowFile.
mime.typeThe mime type of the attachment.

https://nifi.apache.org/components/org.apache.nifi.processors.email.ExtractEmailAttachments/ 

Under those MIME types, you should be able to get the text/plain or text/html with the body content of the email, as you need. 


Regards,
Andrés Fallas
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs-up button.

avatar
Expert Contributor

could you please elaborate 
and also javax.mail. type of import is not available in nifi 2.8 could you please tell if we have some other type for importing.