I’m sure you all are familiar with the Nuxeo package called Nuxeo IMAP Connector. This connector lets you handle emails in the Nuxeo Platform. This package is really convenient when it comes to fetching emails from a given inbox and create a corresponding email document within the Platform. You can then plug your business rules into it and create some interesting features. You can find detailed documentation about it here.
Speaking of business rules, I recently created one, and in this blog, I will walk you through the use case, implementation, and result.
The Use Case
Each project in the Nuxeo Platform is represented by a folder and some predefined hierarchy and each project is identified by a custom ID. This ID is composed of a number (a counter) and the creation date of the project with the format: ddMMyyyy. For eg: 89-05252016
The goal was to be able to transfer emails related to a project directly into the project folder within the Nuxeo Platform.
A Generic Email for All Projects
The first option was to have a generic email address and something like [89-02252016] in the subject line of the email in order to be able to find the related project folder. From that point, every time the system fetches an email, it parses the subject, checks whether there’s an ID, and then tries to find the corresponding project folder. If the corresponding project folder exists then the email is moved into that folder.
This is done with a Document Created Event Handler that calls an automation script, which:
- Parses the subject line - Gets the ID from the brackets - Queries against the projects to retrieve the corresponding one - Moves the email into the folder
Although this is a common solution used in multiple email routing services, it wasn’t really satisfying. The problem was that it required the end user to remember the ID of the project each time he wants to transfer an email to the project folder, which wasn’t very user friendly.
A Unique Email for Each Project
The second option was to create a dedicated email address for each project. It could have been a good thing but then it meant that every time you create a project you have to manually setup a new email account. This is really cumbersome and unproductive.
A Generic Email with a New Alias for Each Project
The third solution and also the one I chose was to create a semi generic email! This is, in fact, something I didn’t know about and our Account Manager, Sebastien Libouban (Seb, as we call him), shared this idea with me. Yes, Account Managers at Nuxeo come up with technical solutions too! :) So, kudos to Seb!
First, you create a generic email address: **[email protected] Then, every time you create a project folder in the Nuxeo Platform, you set the email address metadata for the project by adding the custom ID in the email. So, for my project with the custom ID 89-05252016, the email address will be [email protected]**
That’s it! No need to create a real email account for it. Emails sent to **[email protected] will arrive in the inbox of [email protected]**, which is an email alias.
It’s much easier to use instead of having to put the ID in the subject, especially with the autocompletion feature that every email client have nowadays.