first javascript:
var mail = actions.create("mail2");
mail.parameters.to = "savic.prvoslav[at]gmail.com";
mail.parameters.subject = "Html test";
mail.parameters.from = "savic.prvoslav[at]gmail.com";
mail.parameters.text = "My name is Savić Prvoslav<b> if you see this it is very bold</b>";
mail.parameters.node=document;
//here you set document to sent via email, you can comment this line if you do not want to send doc :)
mail.execute(document);
you can download jar-source-file .
How to install:
put jar file in alfresco/web-inf/lib , restart alfresco, use the javascript.
How to set up Outbound Email Configuration for Gmail:
alfresco3.3G\tomcat\shared\classes\alfresco-global.properties
#
# Outbound Email Configuration
#-------------
mail.host=smtp.gmail.com
mail.port=465
mail.protocol=smtps
mail.username=username
mail.password=pass
mail.smtps.starttls.enable=true
mail.smtps.auth=true
mail.from.default=defaultEmail
How to set up Outbound Email Configuration for Gmail:
alfresco3.3G\tomcat\shared\classes\alfresco-global.properties
#
# Outbound Email Configuration
#-------------
mail.host=smtp.gmail.com
mail.port=465
mail.protocol=smtps
mail.username=username
mail.password=pass
mail.smtps.starttls.enable=true
mail.smtps.auth=true
mail.from.default=defaultEmail
In case of passing the rapidshare.limit just post comment and I will update file for you.
Very Good article. Worked fine for me. In addition to this, Can u update the script for the wf. Like
ReplyDeletemail.parameters.node=bpm_package.children[0];
mail.execute(bpm_package);
Thanks Prvoslav for your post.
My plan is to make change to be able to send bunch of files that are in wf.
ReplyDeletemail.parameters.node=bpm_package;
mail.execute(bpm_package);
Hi Savic,
ReplyDeleteThanks for the article! By the way have you had any problems with the smtp.gmail.com server? When I try it I get the next exception:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Thanks,
Luis
No problem, will be many more ...
ReplyDeleteabout your problem this is common problem, i think that I solved it with this ( but no guarantee on this)
http://blogs.sun.com/gc/entry/unable_to_find_valid_certification
is there another mirror link for the jar file? file not found on rapidshare. thanks
ReplyDeleteJust updated the download link, you can download now.
ReplyDeletePS: thanks for notifying me.
Hi savic
ReplyDeleteis it possible to automatically send an email to the reviewer by just adding the javascript code in workflow-options.jsp?
added
function sendMail(){
var mail = actions.create("mail2");
mail.parameters.to = "receiveMail[at]gmail.com";
mail.parameters.subject = "Html test";
mail.parameters.from = "testMail[at]gmail.com";
mail.parameters.text = "test";
mail.parameters.node=document;
mail.execute(document);
}
then create a button for send notication: (onClick='sendMail()')
Thanks.
I have tried this but did not work. Any how document in javascript ( normal js) is something else :"The JavaScript Document object is the container for all HTML HEAD and BODY objects associated within the HTML tags of an HTML document." ... so sorry for this, what you should do is run this action from java, you can do that too if you need this.
ReplyDeleteJust tried to download the jar file. Says limit of 10 already reached. Any chance of updating the link again?
ReplyDeleteI have uploaded new files.
ReplyDeleteVery nice! Thanks you. This is just what I was looking for since email containing content of Alfresco Site Blogs and Discussions need to use html. The content of these is in html, now the email can be in html. Yipppeee!
ReplyDeleteNo problem , glad to help!
ReplyDeleteHey Savic,
ReplyDeleteIt seems that link is not working.
It will be greate fully if you provide some other images.
Thanks a lot in advance
Akshat
New upload files provided .
ReplyDeleteI downloaded the action today, does this version support sending multiple attachments?
ReplyDeletecurrently no, but you can change the code for this. you would add about 10 lines of code.
ReplyDeleteAlso would be nice to send me a copy.
can you send me your updated jar which will can send multiple attachments?
Deletethanks!
medeljr.mendoza@gmail.com
I'm having the same issue. I can't send multiple attachment.
DeleteDo you have any code to fix this thing sir ?
Thanks .
robin.oria@gmail.com
There is a great demand with this feature, i will try in the near future to do an update on this on my new blog.
DeleteI tried to run the action from a javascript behaviour and received an error when I provide a node value. If node parameter is not used, the email is sent okay. Only when the node parameter is populated is the error generated. I also tried running it from a javascript space rule, in this case, everything works fine. Thanks Steve
ReplyDeleteCaused by: java.lang.IllegalArgumentException: FacesContext must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:50)
at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
at org.alfresco.web.bean.repository.Repository.getServiceRegistry(Repository.java:584)
at org.alfresco.sample.CustomMailActionExecuter$1.prepare(CustomMailActionExecuter.java:340)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:353)
We are Facing the same Issue using your Jar File(both pre compiles and code) in alfresco 4.0 (Build from svn).
DeleteHave you resolved this Issue.
Please guide on this issue,we are stuck at this.
Are you using this in alfresco browse or in share ?
DeleteThanks For your quick response
DeleteIn Alfresco Share UI & Content RULEs [execute javascript] it gives this exception;
We also observe that:
If we execute it anytime from Alfresco UI, it works well AND afterwards the exception doesnt come in Share UI also.
Thanks again.
I really do not know, but this was designed to work i alfresco browser not share. You have the code, so you can change it as you please. If you make it work in share be kind enough to send me the code please :)
DeleteCan you please guide us to resolve this issue.
DeleteCaused by: java.lang.IllegalArgumentException: FacesContext must not be null
at org.springframework.util.Assert.notNull
Thanks
Hi Steve, how are you running the code when it does not work?
ReplyDeleteScenario where the error message is generated -- I attach a behaviour to the onNodeUpdate policy which executes a javascript function which lives on the classpath. In the javascript I am writing a new node and once the node is saved, that noderef is used for the mail parameter (node).
ReplyDeleteThanks for your help.
I've noticed in my user interface that triggers the onUpdateNode behaviour, that it waits till the behaviour completes before allowing the user to take another UI action. When I add an attachment, depending on the size of the attachment, I am expecting the delay will become greater. I looked at the source code you provided and I don't see the async paramter specified. In the ActionService there is an async paramter - http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/action/ActionService.html#executeAction%28org.alfresco.service.cmr.action.Action,%20org.alfresco.service.cmr.repository.NodeRef,%20boolean,%20boolean%29 Any idea how to implement this?
ReplyDeleteThanks Steve, I will see to fix this problem today or tomorrow and post an update here .
ReplyDeletethanks for your help!
can u Describe about imagemagick and openoffice integration in alfresco with proper steps
ReplyDeleteThere is no need, you already have this online.
ReplyDeletehttp://wiki.alfresco.com/wiki/Setting_up_OpenOffice_for_Alfresco
http://wiki.alfresco.com/wiki/ImageMagick_Configuration
Sadly MegaUpload is dead :(
ReplyDeleteCan you please put your JAR somewhere else?
yea, chaned the link hope it works for you.
ReplyDeleteYour source file (sample.zip) you provide above consist of *.java file. When I try to rename zip to jar and load it in Alfresco, surely it gives me "NoClassFound exception". I guess I need to compile *.java file into *.class file.
ReplyDeleteProblem is that I'm very far from JAVA programming and I don't know how to do that in a simple way. Can you help me in this matter?
I'm still using Alfresco Community v3.2.0 (2039) version in my production system. (Yes I know it's old, buggy and sucks :)
Well idea is to give you the source so you can do with it what you want. Here is the link for real jar file, so if it works let me know .
ReplyDeletehttps://e-75.netdokumenti.com/sd?ID=1331817492796
Thanks! You're as fast as always :)
ReplyDeleteSadly it didn't work for me because Alfresco 3.2.0 doesn't have this TestModeable class/interface. Oh well :(
To tell the truth, I actually was searching just for original Alfresco 3.2.0 (2039) version MailActionExecutor class fix to not send user initiated mails using user e-mail address in "mail.from" field by default. This is really ridiculous limitation of Alfresco and sadly they will not even try to fix that:
https://issues.alfresco.com/jira/browse/ALF-1566
This fix is more than simple and I can fix it in MailActionExecutor.java file by changing 1-2 lines, but I can't compile it.
As I said I'm far from JAVA programming, but I have >10 year exp.in PHP, CSS, HTML etc...
Also I couldn't find Alfresco 3.2.0 (2039) version SDK download anymore (I guess I searched for it badly).
This comment has been removed by the author.
ReplyDeleteI have already made a few modifications to spring files in past and so on. It's not a problem.
ReplyDeleteMy problem is that I can create custom (or modify) *.java source file, but I can't compile it to *.class file and without compiling java file to class file nothing will work, right? :(
You have to know a bit of spring...
ReplyDeletefind "action-services-context.xml"
find <bean id="mail" class="org.alfresco.repo.action.executer.MailActionExecuter"...
create class that extends mailaction... and add your code.
put class in my jar, you have xml file there, add a copy paste bean definition just replace the class part. remove all my classes and bean definitions.
note : override this method afterPropertiesSet().
can you send me code for modification, will send you class file :).
ReplyDeleteHere it is. Only thing is that probably class name should be different than default MailActionExecuter.
Deletehttp://files.fm/u/fycbgkg
Changes are starting in line 360
DeleteThis comment has been removed by the author.
ReplyDeleteWill try to send you class file during today or tomorrow
ReplyDeleteGreat, thanks a LOT !!!
DeleteHi!
DeleteI don't want to bug you, but did you manage to compile this classfile ? :)
I am really sorry, I was sick and was not working :(
ReplyDeleteNo problem mate! I hope you're better now.
DeleteIt's just - I have to manually forward ~100 mails daily to our clients because of this and I want to get rid of that :))) lol
Oh man, I'm desperately waiting on this :)
DeleteAny news? Or maybe you can point me to some URL where something similar has already been done and updated *.class (not only *.java) file for Alfresco 3.2.0 is downloadable?
https://e-75.netdokumenti.com/sd?ID=1332241387913
ReplyDeletehere it is.
It looks that it's working now as I imagined.
DeleteThanks a LOT! You're the best :)
I wonder if you can help me. After a friend helped me install alfresco, I lost my password for admin. I am the only user so far. You mentioned in the alfresco forum that there is a way to do this "in java coding and adding new servlet". If as I suspect, this is the only thing left to do, I would be very grateful to know how.
ReplyDeleteMany thanks
Huw Roberts
Are you a programmer or just user with admin rights?
ReplyDeleteI'm not a programmer, so I wouldn't be able to do anything complicated. Was just hoping not to have to reinstall everything.
ReplyDeleteOh no, reinstalling is not needed (you can do it if you do not have any data that is important :D )
ReplyDeleteDo you know how to add servet, so I would send you only the important code (that resets password about 10 lines of code), or you need jar file, with compiled java class ?
If it's just a matter of resetting 10 lines of code, I'm sure I can do that if you can tell me where exactly.
ReplyDeleteIf it's not as simple as that, I'll still give it a try if you'll bear with me. I am new to this. Thanks.
Yes, will try to send you code tomorrow. currently am not at home :(
ReplyDeleteThanks Prvoslav
ReplyDeleteHi,
ReplyDeleteI've try to integrate this jar in my alfresco 3.4 community.
When i try to send a simple mail without any attachment i have this error :
org.springframework.extensions.webscripts.WebScriptException: 06100006 Internal error
caused by:
java.lang.NullPointerException
Can you help me?
Thanks
Now it's work, but the from parameter not working.
DeleteCan you elaborate on your problem on this?
DeleteWorks like a charm! Great post, great job!
ReplyDeleteThanks!
does this work on 4.2.c? if so how do you set it up exactly. instruction are not very clear?
ReplyDeleteHi, it should work.
DeleteYou have to create project in eclipse and import the code there. Then deploy it.
So if you can run this example you can use this code with no problem.
http://wiki.alfresco.com/wiki/Custom_Actions
i created project in netbeans. compiled the java file. made a jar under build in the netbeans project. copied the jar file to tomcat/shared/lib in alfresco. copied the xml file to extension. get following error below
Deletei put the jar under tomcat/webapps/alfresco/webint/lib however the `mail.parameters.node=document;` does not attatch any document. i still get blank email. what am i missing?
DeleteYOu are running script in alfresco or share ?
Deletei got it working. put jar under webapps/alfresco... however on line 364 of java file `message.addAttachment("test", file);` how do i replace "test" with the filename of the node?
DeleteThis comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteThanks for the source, I am facing ArrayOutoFBound Exception while executing this code.
org.springframework.mail.MailPreparationException: Could not prepare mail; nested exception is java.lang.ArrayIndexOutOfBoundsException: 2
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:367)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy113.send(Unknown Source)
at org.alfresco.repo.action.EmailNotification.executeImpl(EmailNotification.java:500)
Please help.
Can you please tell what is the email templeate to be used with your code to have the email ?
ReplyDeleteHello,
Deleteyou can set template with .template=nodeRef
This comment has been removed by the author.
ReplyDeleteFirst thanks for your solution
ReplyDeleteI installed the jar file in alfresco 4.2e with java 1.6.31 and working properly.
The problem is that I have another rule to "share" that runs a js file. and it works fine but when I install your solution gives me java errors. If I remove your solution works well.
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteI am facing following issue.
2014-07-22 19:15:36,604 ERROR [action.executer.MailActionExecuter] [pool-5-thread-2] Failed to send email to xyz@gmail.com
org.springframework.mail.MailPreparationException: Could not prepare mail; nested exception is java.lang.NullPointerException
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:367)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy142.send(Unknown Source)
Please help.
Thanks
From your exception i can not see what is wrong with the code :(
DeleteHi,
ReplyDeleteCode ::
var mail = actions.create("mail2");
mail.parameters.subject = "Reminder" + bpm_workflowDescription;
mail.parameters.from = initiator.properties["cm:email"];
mail.parameters.text = "Kindly process the document: " ;
var members = people.getMembers(bpm_groupAssignee);
var document = bpm_package.children[0];
for(var x in members) {
logger.log("Member is: " + members[x].properties.email);
mail.parameters.to = members[x].properties.email;
mail.parameters.node=document;
mail.execute(bpm_package);
}
We have written this web script. I am trying to execute this webscript in alfresco share.
And we are facing following issue.
2014-07-22 19:51:45,414 ERROR [transaction.support.TransactionSynchronizationUtils] [pool-5-thread-2] TransactionSynchronization.afterCompletion threw exception
java.lang.IllegalStateException: No value for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@2500091c] bound to thread [pool-5-thread-2]
at org.springframework.transaction.support.TransactionSynchronizationManager.unbindResource(TransactionSynchronizationManager.java:199)
at org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization.suspend(SqlSessionUtils.java:243)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.doSuspendSynchronization(AbstractPlatformTransactionManager.java:666)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.suspend(AbstractPlatformTransactionManager.java:569)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:418)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:347)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
Please help me.
Hey Savic,
ReplyDeleteIt seems that link is not working.
Please provide some other images.
Thanks a lot.
Hello,
Deletethis is done for quite old alfresco version.
Upgrade is needed :(
Update is needed. Link is broken :(
ReplyDeleteFor Alfresco 5.1e org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mail2' is defined