Page 1 of 2

script import mail

PostPosted:Mon Jun 30, 2014 9:35 pm
by snowman
Hello,

I want to import emails provided as .eml to openkm. When I do this manually (i. e. clicking on import in the ui) it works fine and converts the mail nicely.
However, then I tried to upload using webdav and no conversion takes place. Now I want to try import using php, but I dont know how to use webservices for this. With openkm 5 is already managed importing documents.But the mail service does not allow using a file for import. The API speaks about a mail object, but the doc is a bit short on it. How do I create it from an .eml file? Can anyone provide a code snippet with the essentials?

Best regards

Re: script import mail

PostPosted:Tue Jul 01, 2014 10:21 am
by jllort

Re: script import mail

PostPosted:Tue Jul 01, 2014 9:21 pm
by snowman
Hello,
thanks for the fast reply. However, I get a 404 when I hit that link.
BTW: I dont program in Java (only c' but not here). Does the source translate to web service? I mean, I understand that there isan object called mail. But how would I make this available in a php script?

Best regards

Re: script import mail

PostPosted:Thu Jul 03, 2014 2:31 pm
by pavila
You can make calls to REST web services (http://wiki.openkm.com/index.php/RESTful_Guide) or use the PHP SDK (http://wiki.openkm.com/index.php/SDK_for_PHP)

Re: script import mail

PostPosted:Fri Jul 04, 2014 8:56 pm
by snowman
Hi,

the php sdk 1.0.1 does not support a mail object. When I try to import the .eml as a file (using OKMDocument->createSimple() ) it does not get parsed,
When I look at the SoapServices I get no clue on how to use it. I cannot put in a file like with "createSimple". I appears that I have to parse the eml manually. But then, when I call "create" there is no target path?
My target is to have to mail objects like files in the file area. The reason is I want to have an exact copy of a subtree of my IMAP account, Actually, I do not like the date based folder structure of the openkm mail area. and it *would* work if I am nuts enough to do it manually.
Is there no way to achieve this?

Re: script import mail

PostPosted:Sun Jul 06, 2014 9:58 am
by jllort
You should do something with automation or crontab task, the idea will be upload the eml files and then convert as mails.

I will try to give you the clues for doing it:
Take a look the class FileUplodServer.java http://sourceforge.net/p/openkm/code/HE ... rvlet.java you're interested in the code from line 571 and 607 ( you should do something similar into automation ).

What do you prefer -> real time conversion with automation or daily crontab task ( probably more easy to be implemented ).

Re: script import mail

PostPosted:Fri Dec 25, 2015 10:25 pm
by snowman
Hello,

is there any update on this topic?
I tried to tackle this issue again using the rest services. But a) I cannot get the C# API to work and B) tried the curl post document example.
The latter uploads an eml file but does no conversion to mail. Which one would be the proper API call to resemble exactly what the manula upload does?
Are there any new developments here?

Best regards,
Snowman

Re: script import mail

PostPosted:Sun Dec 27, 2015 10:21 am
by jllort
Last week we had been working on creating two new methods for importing directly eml and msg files. You are on truth, when you upload files with api the msg and eml files are not automatically converted, there's some login in servlet what is doing it from UI. If you take a look at FileUploadServlet.java class http://sourceforge.net/p/openkm/code/HE ... rvlet.java you'll see this piece of code.

Here you have two option, wait until we release the change on community and sdk or based on document creation ( event ) do the conversion from msg, eml file to mail ( based on FileUploadServlet.java class ). I think we will be able to release these changes on first weeks of January.

Re: script import mail

PostPosted:Mon Feb 20, 2017 9:40 pm
by snowman
Hello,

is there any news on uploading an .eml to the file area ending up as an email object using the API (REST preferred)?
Or any other scriptable way to get emails into the file area showing up as emails?

Best regards

Re: script import mail

PostPosted:Tue Feb 21, 2017 7:42 pm
by jllort
This week we have finished to build the package of the new community release. This will be a major release what will comes with imporEml and importMsg methods from rest. I think will be able to finish the process in 1-2 weeks. Also we will unlock the new documentation what is also finished.

Re: script import mail

PostPosted:Sat Apr 15, 2017 8:13 pm
by snowman
Hello,

I upgraded to Version 6.3.3 now. My issue is still to import email (as eml files) into the file area using a scripted way.
Can this be done using rest "importEml" ? How can I parametrize it using curl?

Thank you,snowman

Re: script import mail

PostPosted:Sun Apr 16, 2017 9:31 am
by jllort
Version 6.3.3 comes with REST Mail service. One of these methods are importEML and importMSG you must use one of them. Take a look at this class https://github.com/openkm/document-mana ... rvice.java

Unfortunately we still have not released a new version of SDK's community version what take advantage of these new features.

Take these url as reference:
Endpoint address: https://demo.openkm.com/OpenKM/services/rest/mail
WADL : https://demo.openkm.com/OpenKM/services/rest/mail?_wadl

Re: script import mail

PostPosted:Tue Apr 18, 2017 9:02 pm
by snowman
Sorry for asking so stupidly.
I am not familiar with java. I understand from the code that I have to pass two parameters: dstId and content.
Is this correct: curl -u user:pass -H "Accept: application/json" -X POST -F dstId=/okm:root/test/testmail.eml -F content=/root/10.eml http://localhost:8080/OpenKM/services/r ... /importEML ?
However, it does not produce anything in the test folder. Sigh.

Re: script import mail

PostPosted:Wed Apr 19, 2017 6:34 am
by jllort
Should be something like it:
Code: Select all
curl -u okmAdmin:admin -H "Accept: application/json" \
   -X POST -F dstId=/okm:root/folder -F content=@testmail.eml \
   http://localhost:8080/OpenKM/services/rest/mail/importEML
dstId must be a folder path or uuid ( not mail final path )

Re: script import mail

PostPosted:Wed Apr 19, 2017 7:05 pm
by snowman
Hi,

thanks for the example. I tried it but it does not work. I guess I get a 404?!
Result of curl:
Code: Select all
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'okmAdmin'
> POST /OpenKM/services/rest/mail/importEML HTTP/1.1
> Authorization: Basic b2ttQWRtaW46YWRtaW4=
> User-Agent: curl/7.28.1
> Host: localhost:8080
> Accept: application/json
> Content-Length: 9569
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------cac721212ed42bab
>
< HTTP/1.1 100 Continue
< HTTP/1.1 404 Not Found
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Allow: POST,GET,DELETE,PUT,OPTIONS,HEAD
< Date: Wed, 19 Apr 2017 18:54:52 GMT
< Content-Length: 0
* HTTP error before end of send, stop sending
<
* Closing connection 0
the exact curl was:
Code: Select all
curl -v -u okmAdmin:admin -H "Accept: application/json" -X POST -F dstId=/okm:root/test -F content=@10.eml http://localhost:8080/OpenKM/services/rest/mail/importEML
The folder "test" exists. The email file "10.eml" exists (it can be imported manually).

For comparision I tried:
Code: Select all
curl -u okmAdmin:admin -H "Accept: application/json"    http://localhost:8080/OpenKM/services/rest/folder/getChildren?fldId=133448de-618a-4b96-adfd-c9a19a615042
This gives the expected JSON result. So I think credentials are ok and rest services are generally available.

Any more ideas?