Solved
How to send the email notification to the entire user group instead of single user.
Hi,
I have a requirement to send the email notification to the group. How can that be done?
Hi,
I have a requirement to send the email notification to the group. How can that be done?
You could fetch the users in a group and iterate through them to get their email ID. Below is a sample code to fetch the user email IDs.
UserManager userManager=jrSession.getUserManager();
Group group = (Group) userManager.getAuthorizable("GroupId");
log.info("group >>> "+group);
final Iterator<Authorizable> memberslist = group.getMembers();
while (memberslist.hasNext()) {
final Authorizable user = memberslist.next();
if (user != null && !user.isGroup() && user.getProperty("./profile/email") != null) {
//EMAIL ADDRESS FOR MEMBERS
Value[] usrEmail = user.getProperty("./profile/email");
for(Value emailGroup : usrEmail) {
log.info("emailGroup line 152>>> "+emailGroup);
}
}
}
Once you have the list of email ids you can use org.apache.commons.mail.HtmlEmail.addTo() to add the list of ids.
Let me know if you still face any issues.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.