How upload mail to alfresco api rest

To upload a mail to Alfresco using the REST API, you can use the POST /alfresco/api/node/{nodeId}/children endpoint with the mimetype set to message/rfc822 and the content set to the email message in RFC822 format.

Here is an example of how to do it using curl:

curl -X POST \
  http://localhost:8080/alfresco/api/node/workspace/SpacesStore/your-node-id/children \
  -H 'Content-Type: message/rfc822' \
  -H 'Authorization: Bearer your-token' \
  -d @email.eml

Replace:

The email.eml file should contain the email message in RFC822 format, including the headers and body.

You can also use the POST /alfresco/api/node/{nodeId}/children endpoint with the mimetype set to message/rfc822 and the content set to the email message in JSON format. Here is an example:

curl -X POST \
  http://localhost:8080/alfresco/api/node/workspace/SpacesStore/your-node-id/children \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer your-token' \
  -d '{"mimetype": "message/rfc822", "content": "Subject: Your Email Subject\r\n\r\nYour Email Body"}'

This will create a new email node with the specified subject and body.

You can also use the POST /alfresco/api/node/{nodeId}/children endpoint with the mimetype set to message/rfc822 and the content set to the email message in base64 encoded format. Here is an example:

curl -X POST \
  http://localhost:8080/alfresco/api/node/workspace/SpacesStore/your-node-id/children \
  -H 'Content-Type: application/octet-stream' \
  -H 'Authorization: Bearer your-token' \
  -d 'SGVsbG8gd29ybGQh'

This will create a new email node with the specified base64 encoded content.

Please note that you need to have the correct permissions and authentication to upload a mail to Alfresco using the REST API.

Also, you can use the Alfresco SDK to upload a mail to Alfresco, it provides a simple way to interact with the Alfresco REST API.

import alfresco.rest.client.RestApi;
import alfresco.rest.client.RestApiException;
import alfresco.rest.model.Node;

RestApi api = new RestApi("http://localhost:8080/alfresco/api");
api.setAuthentication(new OAuthTokenAuthentication("your-token"));

Node node = api.getNode("workspace/SpacesStore/your-node-id");
Node emailNode = new Node();
emailNode.setMimetype("message/rfc822");
emailNode.setContent("Subject: Your Email Subject\r\n\r\nYour Email Body");
node.addChild(emailNode);

Please note that you need to have the correct permissions and authentication to upload a mail to Alfresco using the Alfresco SDK.