• script import mail

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #29110  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
 #29133  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
 #29167  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?
 #29175  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 ).
 #41122  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
 #41124  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.
 #43259  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
 #43269  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.
 #43617  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
 #43619  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
 #43630  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.
 #43634  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 )
 #43642  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?

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.