// Common @RequestMapping(value = "/mail/send.do") public ModelAndView viewSendMail( @RequestParam(value = "userId", required = false) List<String> userIds, @RequestParam(value = "bid", defaultValue = "0") int boardCodeId) { ModelAndView modelAndView = new ModelAndView("/mail/send"); List<MailView> mails = new ArrayList<MailView>(); MailList mailList = new MailList(); List<TeamCodeView> teamCodeList = null; // 한 경진대회 참가자들에게 메시지 보내기 if (boardCodeId != 0) { teamCodeList = teamService.findTeamCodes(boardCodeId, null); for (TeamCodeView tcv : teamCodeList) { List<TeamView> teamList = teamService.findTeams(tcv.getTeamCodeId()); for (TeamView tv : teamList) { MailView mv = mailService.getEmail(tv.getUserId(), null, null); if (mv != null) mails.add(mv); } } } // 선택한 참가자들에게 메시지 보내기 if (userIds != null) { for (String userId : userIds) { MailView mv = mailService.getEmail(userId, null, null); if (mv != null) mails.add(mv); } } mailList.setMails(mails); modelAndView.addObject("mailList", mailList); modelAndView.addObject("subTitle", "메일보내기"); modelAndView.addObject("mypageType", "send"); return modelAndView; }
@RequestMapping(value = "/mail/sendMail.do") public String sendMail( @RequestParam("mailList") List<String> userIds, @RequestParam(value = "title", required = false) String title, @RequestParam(value = "content", required = false) String content) { if (userIds != null) { for (String userId : userIds) { MailView mv = mailService.getEmail(userId, null, null); // Send a composed mail mailService.sendMail(mv.getToMail(), title, content); } } return "redirect:" + "/mail/send.do"; }