I suppose the bean class org.alfresco.repo.action.executer.MailActionExecuter should be extended to make this possible. It uses org.springframework.mail.javamail.JavaMailSenderImpl which can send email with attachments.
How can I order the extended version of MailActionExecuter to send email with attachment? What command should I put into the process definition?
Being an Alfresco newbie, I hope I express myself clear. Thanks in advance for your reaction.
As I understand, you can write your own action classes, which will be callable from AlfrescoJavaScript - if you set the appropriate spring configuration files correctly. (http://wiki.alfresco.com/wiki/JavaScript_API#Actions_API)
What I did (just to test this):
I rewrote bean class MailActionExecuter by adding a dummy variable foo + a getter and settermethod. I compiled this as a jar file, which I added to directory /alfresco/WEB-INF/lib/ I rewrote following the lines of '\alfresco\WEB-INF\classes\alfresco\action-services-context.xml':
<start-state name="start"> <task name="ovs:startaanvraag" swimlane="initiator"></task> <transition name="" to="ControleerAanvraag"></transition> <event type="node-leave"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <script> var wf_Document = bpm_package.children[0]; var strEmail=""; var Straat=""; <!– Ontvangst bevestiging sturen naar de aanvrager –> if (wf_Document.properties["omgevingsvergunning:aanvragertype"]=="Particulier"){ strEmail=wf_Document.properties["omgevingsvergunning:emailadres"]; Straat=wf_Document.properties["omgevingsvergunning:adres"]; }else{ strEmail=wf_Document.properties["omgevingsvergunning:bd_emailadres"]; Straat=wf_Document.properties["omgevingsvergunning:bd_adres"]; } var mail = actions.create("mail"); mail.parameters.to = strEmail; mail.parameters.subject = Straat + " (1) Ontvangst omgevingsvergunning aanvraag nr "+wf_Document.properties["omgevingsvergunning:aanvraag_dossiernummer"]; mail.parameters.from = "noreply@briksendam.nl"; mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/OmgevingsvergunningETemplates/OntvangstBevestiging.ftl"); mail.parameters.text = "Uw aanvraag voor een omgevingsvergunning is ontvangen en zal zo spoedig mogelijk intern worden doorgezonden ter verdere behandeling."; mail.execute(wf_Document); mail.parameters.to= "overzicht@briksendam.nl";
mail.parameters.foo = "this is what I have added…";
This does not work actually. Tomcat log file gives 14:55:00,500 ERROR [action.executer.MailActionExecuter] Failed to send email to T.Abarki@briksendam.nl java.lang.NoClassDefFoundError: org/alfresco/service/cmr/repository/TemplateNode at com.atosorigin.repo.action.executer.MailAttachmentActionExecuter.createEmailTemplateModel(MailAttachmentActionExecuter.java:332) at com.atosorigin.repo.action.executer.MailAttachmentActionExecuter.access$4(MailAttachmentActionExecuter.java:326) at com.atosorigin.repo.action.executer.MailAttachmentActionExecuter$1.prepare(MailAttachmentActionExecuter.java:278) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:347) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:339) at com.atosorigin.repo.action.executer.MailAttachmentActionExecuter.executeImpl(MailAttachmentActionExecuter.java:312) … lots of code
Maybe I just did something wrong with Tomcat. I just want to know: am I right about AlfrescoJavaScript? Can you write your own Action classes and call them with AlfrescoJavaScript, or is it more to be done? Is it something I don't understand, or is it something that is not possible yet?