Coding with the Hub #3 - Alfresco Extract Email Attachments

cancel
Showing results for 
Search instead for 
Did you mean: 

Coding with the Hub #3 - Alfresco Extract Email Attachments

angelborroy
Alfresco Employee
2 0 1,999

In Alfresco Repository, mail files are stored as they are, in a single repository node that includes information about the body of emails and their attachments.

Some Enterprise add-ons, such as the Outlook Connector, add features to this default behaviour. For those users, this development is not recommended.

However, if you are using Community or Enterprise edition with no enhancements, this addon will allow you to extract mail attachments and to store them as separate nodes in the Alfresco Repository. For example, for an email with two attachments, you will get one node with the email body and two additional nodes with the files attached to it.

 

Alfresco Maven SDK

It's recommended to review this information from Alfresco Docs to understand deployment process:

Building this feature using the Alfresco Maven SDK requires creating a JAR file to be deployed inside the Alfresco Repository Web Application. In this case we are using the Maven "alfresco-platform-jar-archetype" to develop a Behaviour listening to the creation of new nodes. Note that our code will be executed by the Alfresco Repository every time a new node is created, inside the database transaction that is actually creating the node. For this reason, we need to be sharp to identify if the new node requires attachments extraction and we need to be extra careful to avoid breaking the file creation due to some unexpected exception in our code.

Source code is available in https://github.com/aborroy/alfresco-outlook-attachments

Follow this steps to build and deploy the project to a Docker Compose ACS 7.2 template:

$ git clone git@github.com:aborroy/alfresco-outlook-attachments.git
$ cd alfresco-outlook-attachments
$ mvn clean package
$ cp target/alfresco-outlook-attachments-1.0.0.jar ../docker/alfresco/modules/jars

Alfresco Java SDK

It's recommended to review this information from Alfresco Docs to understand deployment process:

As an alternative, the feature can be built using the Alfresco Java SDK. In this case is not required to deploy any JAR file to Repository, we're creating a Spring Boot application that is consuming Repository Events from ActiveMQ. When a creation event is detected, the application will identify if that requires attachment extraction and it will update the Alfresco Repository using the REST API. Note that our code will executed outside the Alfresco Repository, once the transaction has been committed in the database. Since we're not affecting directly ingestion performance, we need to take care of the REST API calls generated to create email attachments.

Source code is available in https://github.com/aborroy/alfresco-outlook-attachments-oop

Follow this steps to build and run the application together with a running ACS 7.2 instance:

$ git clone git@github.com:aborroy/alfresco-outlook-attachments-oop.git
$ cd alfresco-outlook-attachments-oop.git
$ mvn clean package
$ java -jar target/alfresco-outlook-attachments-oop-5.1.4.jar

Video recording

Additional details are provided in this video:

About the Author
Angel Borroy is Hyland Developer Evangelist. Over the last 15 years, he has been working as a software architect on Java, BPM, document management and electronic signatures. He has been working with Alfresco during the last years to customize several implementations in large organizations and to provide add-ons to the Community based on Record Management and Electronic Signature. He writes (sometimes) on his personal blog http://angelborroy.wordpress.com. He is (proud) member of the Order of the Bee.