List of usage examples for com.liferay.portal.kernel.messaging Message setDestinationName
public void setDestinationName(String destinationName)
From source file:it.dontesta.liferay.messagebus.example.mvc.SendEmail.java
License:Open Source License
/** * Send a list of no active user by Email Sender * /* www . j ava 2 s . c o m*/ * @param actionRequest * @param actionResponse * @throws IOException * @throws PortletException * @throws SystemException */ public void sendEmailByEmailSender(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException, SystemException { User user = (User) actionRequest.getAttribute(WebKeys.USER); List<User> userList = getInactiveUsers(user); String emailBody = getEmailBody(userList); if (userList.size() > 0) { InternetAddress from = new InternetAddress("noreply@liferay.com", "Liferay Portale"); InternetAddress to = new InternetAddress(user.getEmailAddress(), user.getFullName()); MailMessage message = new MailMessage(from, to, "List of disabled users", emailBody, false); Message myMessage = new Message(); myMessage.setDestinationName(DestinationNames.MAIL); myMessage.setPayload(message); MessageBusUtil.sendMessage(myMessage.getDestinationName(), myMessage); SessionMessages.add(actionRequest, "email-userlist-no-active-send-successfully"); } else { SessionErrors.add(actionRequest, "email-userlist-no-active-count-zero"); } }