cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript to send email to everyone but the author

joemc3
Champ in-the-making
Champ in-the-making
I'm looking to build a webscript that will send email notification to everyone in the site BUT the author who just uploaded or modified the document.  Ideally, I would then have this script kicked off as part of a rule on the folder. 

Does anyone have any code that does anything like this or have any pointers to get me in the right direction?

Thanks in advance.
5 REPLIES 5

mitpatoliya
Star Collaborator
Star Collaborator

joemc3
Champ in-the-making
Champ in-the-making
I didn't see anything on that linked that answered my question.  I'm looking for a way to email everyone EXCEPT the person to uploaded or updated the document.

jego
Star Contributor
Star Contributor
Hi joe,

I would recommend you to write a java policy for that to get notified when a document is updasted. You can use the siteservice to list the site members and filter out the current user who uploads the document. You can than use the mail action to send a mail to each site member.

Hope that helps, even if the answer is a little bit late 🙂
Jens

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
You can create a rule taht executes small javascript code, that will send emails.

email sending would be easy for loop , using this call
http://wiki.alfresco.com/wiki/4.0_JavaScript_Services_API#Get_list_of_site_members

then in a loop you can send emial using some of the code here
http://stackoverflow.com/questions/12075743/how-to-send-email-in-alfresco-4

—-
no programming skils required.

hardik_t_mistry
Champ in-the-making
Champ in-the-making
Hi Joe,

You need to write a Java Policy of alfresco. Your policy implementation class will need to implement <java>NodeServicePolicies.OnCreateNodePolicy</java> interface and write its <java>onCreateNode()</java>. Now whenever a new node is created, this <java>onCreateNode()</java> will be called. So in this method you need to
1) Get site name in which document has been uploaded
2) Get all members of the site and make a list of members excluding current user/uploader/author
3) Once you have members list, get their registered email id(Get PersonNode from the username and from PersonNode get their email id)
4) you can use Java Mail API to send mail to all of them.

In Policy class of the Alfresco, you also can specify if you want to send the mail when some special type(custom type) of document or document with special aspect is uploaded. You will need to define this in Policy class's <java>init()</java>.