Page 1 of 1

How to extract only attachements of eMails

PostPosted:Mon Mar 18, 2019 5:47 pm
by OpaHeinz
Hello together
I used OpenKM Script to import Mails into it. Everything works fine.

But my requirement is, to import only the attachments of my eMail account into OpenKM, into a specific folder.

I thought about a cron job, which connects to my eMail account and takes each night all delivered eMail attachments into an OpenKM Folder.

Did anyone had an idea/experience how to handle this/ similar solution / script, of such a requirement?
?

Thank you in advance
OpaHeinz

Re: How to extract only attachements of eMails

PostPosted:Thu Mar 21, 2019 7:46 pm
by jllort
Usually this kind of problems are solved into OpenKM in a different manner. Upload the mail with attachment, for your information about the mail creation life cycle. First it is created the mail node without attachments, later are added the attachments, what at the end are standard documents what they have a parent of type Mail.

You should use Automation -> document create event and evaluate when a document parent is an email or not. For example:
1- upload mails into /okm:root/mails
2- set a automation task rule to check documents created into /okm:root/mails and check if they are have a parent of type Mail.
3- in case documents have a parent of type Mail then move these documents where you wish
4- schedule a crontab task to purge mails from /okm:root/mails what will be older of 24h

Re: How to extract only attachements of eMails

PostPosted:Fri Mar 22, 2019 2:15 pm
by OpaHeinz
Hello Jilort
thank you for replying!

I tried like you suggested, but there is probably a knowledge gap.
I created a rule if a dokument in /okm:root/mails is created
But I am not able to find a solution to check "a parent of type Mail"

Would it be possible to get a little bit more details?

Thank you in advance
rgds
OpaHeinz

Re: How to extract only attachements of eMails

PostPosted:Sat Mar 23, 2019 9:41 am
by jllort
Let's go with a sample:
You have an email at
1- /okm:root/mails/Some-Email ( with an attachmed what mean into OpenKM is stored into soemthing like /okm:root/mails/1234-Some-Email/document.pdf ( do not worry about 1234 in front of the path, the reason is to be able to upload several email with same name ))

2- If you create a automation rule based on document creation in path /okm:root/mails/ will be raised the event in document creation /okm:root/mails/1234-Some-Email/document.pdf

Then you only must check if parent of document.pdf is a Mail the steps are:
1- convert uuid to path -> https://docs.openkm.com/kcenter/view/ok ... etNodePath
2- get parent path -> https://docs.openkm.com/kcenter/view/ok ... #getParent
3- check if the parent is an email -> https://docs.openkm.com/kcenter/view/ok ... ml#isValid