среда, 25 февраля 2015 г.

Alfresco 5.0.a Send Email with attachments

Several days ago I was faced with a problem that Alfresco doesn't allow to send email with attachments and I written small patch to add this feature. I believe this AMP will be useful for somebody.

Addon was tested on Alfresco 5.0.a

What do you need to do:

  1. Download amp 
  2. Put this file into {Alfresco}/amps folder
  3. Stop Alfresco
  4. Run script {Alfresco}/bin/apply_amps.sh
  5. Run Alfresco
  6. After that you will get ability to send email with attachments

How to send email with attachments (example):

    
// create email
var mail = actions.create("mail");

// set receiver of the email
mail.parameters.to = "to.somebody@gmail.com";

// set mail subject
mail.parameters.subject = "Email with attachments";

// set sender of the email
mail.parameters.from = "from.somebody@gmail.com";

// set mail body
mail.parameters.text = "This is my first email with attachments";

// initialize array of attachments
var array = [];

//add document to array
array.push(document.nodeRef);

//add one more document to array
array.push(document1.nodeRef);

// add attachments to the email
mail.parameters.attachments = array;

// send email
mail.execute(document);