Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

ConsumeEWS processor - How to read an email using Apache Nifi and extract attachment

avatar
New Contributor

Hi All,

 

I am trying to read an email from my outlook account and fetch the attachment. I am using the ConsumeEWS processor since my account is in the cloud and i am not able to use IMAP or POP3.

 

I am able to connect to my mailbox and fetch the mails. This is the flow i am using.

CosumeEWS -> ExtractEmailHeaders ->RouteonAttribute -> ExtractEmailAttachments -> PutFile

 

this how i am routing the mails.

${anyMatchingAttribute("email.headers.from.*"):contains("mailid"):and(${email.attachment_count:gt(0)})}

 

But the problem is

- I am not able to fetch the attachments. The flow files are in MIME format and it is not fetching the attachments. When i route on attribute attachments greater than 1 , all the mails and the ones without attachment are also getting passed. The attachment fetched is looking like the mail body.

- I am getting only few of the mails fetched and these mails are getting fetched repeatedly

 

Please help in solving this issue.

3 REPLIES 3

avatar
New Contributor

Same issue. Do you solution?

avatar
New Contributor

For now i have a solution. 

Firstly i was making few mistakes, so i rectified it.

- I made the job to be scheduled to run at a certain time or else it keeps pulling the same email multiple times. Also it is able to pull only unread emails. So that is a drawback. So you can mark the email as read after fetching. In that way it will only pull the mail once. By this i was able to fetch all incoming unread emails.

- Still the mail is in a unreadable mime format, so the extract attachment processor cannot read and extract the attachment. So we need to remove the unwanted lines from the mime file . So i wrote a Unix script to remove unwanted lines and text from the mime file and then passed it to the extract attachment processor and voila it was able to fetch the attachment perfectly. I had to play around with the mime file. You need to open the mime file and keep only the From,To,Subject and Attachment content of the mime file and remove rest of the content.

 

Rite now this is working for my requirement. Hope this helps.

avatar
New Contributor

Hi, could you please share an example of MIME file, which is acceptable for spliting?

I'm tried to do some workaround tests, but in all cases MIME file goes to "Oridginal"  queue.