cancel
Showing results for 
Search instead for 
Did you mean: 

How send an Email to many 'external users' using MailAction

angello0571
Champ on-the-rise
Champ on-the-rise
Hello,

I tried to use the MailAction, it only recieves a list of users's usernames or groups. For Example:

 this.serviceRegistry = AlfrescoServiceUtil.getServiceRegistry();
      List<String> users = new ArrayList<String>();
      users.add("user1");
      users.add("user2");
      ActionService actionService = serviceRegistry.getActionService();
      Action mailAction = actionService.createAction(MailActionExecuter.NAME);
      mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "My Subject");
      mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, "someone@gmail.com");
      mailAction.setParameterValue(MailActionExecuter.PARAM_TO_MANY, (Serializable) users);
      mailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, "Hello!");
      actionService.executeAction(mailAction, null);

That code works perfect, but I would like to send an email to a list of email adresses (they don't live into Alfresco as users or groups, they are external). Is there any way to do something like this?:

 this.serviceRegistry = AlfrescoServiceUtil.getServiceRegistry();
      List<String> users = new ArrayList<String>();
      users.add("extarnaladress1@hotmail.com");
      users.add("extarnaladress2@gmail.com");
      ActionService actionService = serviceRegistry.getActionService();
      Action mailAction = actionService.createAction(MailActionExecuter.NAME);
      mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "My Subject");
      mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, "someone@gmail.com");
      mailAction.setParameterValue(MailActionExecuter.PARAM_TO_MANY, (Serializable) users);
      mailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, "Hello!");
      actionService.executeAction(mailAction, null);

Or do how I can extend the API to do it ?
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
You could add your own action that does what you want.

angello0571
Champ on-the-rise
Champ on-the-rise
Thank you mrrogers Smiley Happy

I built my own action based in the MailActionExecuter (I took it from http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/jav...), and I just remove the validation against Person and Groups in the Alfresco Repository. After that I configured my bean MailCustomActionExecuter in the action-services-context.xml.

Now I'm able to send email to external addresses Smiley Happy

My next goal is attach files sending emails. If I get it, then I write a post about it.

Regards