/** * @param rundata * @param context * @param msgList * @return */ @Override protected boolean deleteFormData(RunData rundata, Context context, List<String> msgList) { try { int index; try { index = Integer.parseInt(ALEipUtils.getTemp(rundata, context, ALEipConstants.ENTITY_ID)); } catch (Exception e) { return false; } String currentTab = ALEipUtils.getTemp(rundata, context, "tab"); int type_mail = (WebMailUtils.TAB_RECEIVE.equals(currentTab)) ? ALFolder.TYPE_RECEIVE : ALFolder.TYPE_SEND; ALMailHandler handler = ALMailFactoryService.getInstance().getMailHandler(); ALFolder folder = handler.getALFolder(type_mail, orgId, userId, Integer.valueOf(accountId)); folder.deleteMail(index); } catch (Exception e) { logger.error("webmail", e); return false; } return true; }
/** * @param rundata * @param context * @param msgList * @return */ @Override protected boolean insertFormData(RunData rundata, Context context, List<String> msgList) { String[] attachmentFilepaths = null; try { FileuploadLiteBean filebean = null; boolean hasAttachments = (fileuploadList != null && fileuploadList.size() > 0); if (hasAttachments) { int size = fileuploadList.size(); attachmentFilepaths = new String[size]; for (int i = 0; i < size; i++) { filebean = fileuploadList.get(i); attachmentFilepaths[i] = ALStorageService.getDocumentPath( FileuploadUtils.FOLDER_TMP_FOR_ATTACHMENT_FILES, userId + ALStorageService.separator() + folderName) + ALStorageService.separator() + filebean.getFileId(); } } // 件名の値を検証 if (subject.getValue() == null || subject.getValue().equals("")) { subject.setValue("無題"); } // 返信メールの場合は,ヘッダを追加する. Map<String, String> map = null; if (getMailType().getValue() == TYPE_REPLY_MAIL || getMailType().getValue() == TYPE_REPLY_ALL_MAIL) { ALLocalMailMessage msg = null; try { msg = (ALLocalMailMessage) WebMailUtils.getSelectedLocalMailMessage( rundata, context, (int) getMailType().getValue()); if (msg == null) { return false; } } catch (Exception e) { return false; } String in_reply_tos = msg.getMessageID(); StringBuffer reference = new StringBuffer(); String[] references = msg.getHeader("References"); map = new LinkedHashMap<String, String>(); if (references != null && references.length > 0) { reference.append(ALMailUtils.getOneString(references, " ")); } if (in_reply_tos != null && (!in_reply_tos.equals(""))) { map.put("In-Reply-To", in_reply_tos); reference.append(" ").append(in_reply_tos); } map.put("References", reference.toString()); } if (map != null && map.size() == 0) { map = null; } String delim = ",;"; // オブジェクトモデルを取得 EipMMailAccount account = ALMailUtils.getMailAccount(userId, accountId); ALMailHandler handler = ALMailFactoryService.getInstance().getMailHandler(); // 送信サーバ情報 ALMailSenderContext scontext = ALMailUtils.getALSmtpMailSenderContext(orgId, account); // 送信メッセージのコンテキスト ALSmtpMailContext mailcontext = ALMailUtils.getALSmtpMailContext( ALMailUtils.getTokens(ALStringUtil.unsanitizing(to.getValue()), delim), ALMailUtils.getTokens(ALStringUtil.unsanitizing(cc.getValue()), delim), ALMailUtils.getTokens(ALStringUtil.unsanitizing(bcc.getValue()), delim), account.getMailAddress(), ALStringUtil.unsanitizing(account.getMailUserName()), ALStringUtil.unsanitizing(subject.getValue()), ALStringUtil.unsanitizing(body.getValue()), attachmentFilepaths, map); int success_send = handler.send(scontext, mailcontext); if (success_send == ALSmtpMailSender.SEND_MSG_SUCCESS) { if (hasAttachments) { // 添付ファイル保存先のフォルダを削除 ALStorageService.deleteTmpFolder(userId, folderName); } } else { if (success_send == ALSmtpMailSender.SEND_MSG_FAIL) { msgList.add("メールを送信できませんでした。アカウント設定が間違っている可能性があります。"); } else if (success_send == ALSmtpMailSender.SEND_MSG_OVER_MAIL_MAX_SIZE) { msgList.add( String.valueOf(FileuploadUtils.getMaxFileSize()).concat("MB を超えるサイズのメールは送信できません。")); } else if (success_send == ALSmtpMailSender.SEND_MSG_FAIL_SMTP_AUTH) { msgList.add("メールを送信できませんでした。SMTP認証の認証に失敗しました。"); } return false; } } catch (Exception e) { logger.error("webmail", e); msgList.add("メールを送信できませんでした。アカウント設定が間違っている可能性があります。"); return false; } return true; }