轉發郵件附件丟了
public class ForwardAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
DynaActionForm m = (DynaActionForm) form;
String to = (String) m.get("to");
HttpSession session = request.getSession(false);
if (session == null) {
throw new SessionTimeOutException();
}
Message message = (Message) session.getAttribute(Constant.SESSION_MESSAGE_KEY);
User user = (User) session.getAttribute(Constant.SESSION_USER_KEY);
MaildirStore store = (MaildirStore) user.getStore();
MimeMessage forward = new MimeMessage(store.getSession());
forward.setSubject("Fwd: " + message.getSubject(),"UTF-8");
forward.setFrom(new InternetAddress(user.getEmail()));
forward.setSentDate(new Date());
forward.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to));
BodyPart mbp1 = new MimeBodyPart();
mbp1.setText("Here you go with the original message:\n\n"+message.getBody());
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mbp1);
BodyPart mbp2 = new MimeBodyPart();
mbp2.setDataHandler(message.getMessage().getDataHandler());
multipart.addBodyPart(mbp2);
forward.setContent(multipart);
Transport.send(forward);
return mapping.findForward("Success");
}
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
DynaActionForm m = (DynaActionForm) form;
String to = (String) m.get("to");
HttpSession session = request.getSession(false);
if (session == null) {
throw new SessionTimeOutException();
}
Message message = (Message) session.getAttribute(Constant.SESSION_MESSAGE_KEY);
User user = (User) session.getAttribute(Constant.SESSION_USER_KEY);
MaildirStore store = (MaildirStore) user.getStore();
MimeMessage forward = new MimeMessage(store.getSession());
forward.setSubject("Fwd: " + message.getSubject(),"UTF-8");
forward.setFrom(new InternetAddress(user.getEmail()));
forward.setSentDate(new Date());
forward.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to));
BodyPart mbp1 = new MimeBodyPart();
mbp1.setText("Here you go with the original message:\n\n"+message.getBody());
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mbp1);
BodyPart mbp2 = new MimeBodyPart();
mbp2.setDataHandler(message.getMessage().getDataHandler());
multipart.addBodyPart(mbp2);
forward.setContent(multipart);
Transport.send(forward);
return mapping.findForward("Success");
}
}
相關文章
- Java郵件傳送帶附件Java
- 【Redmine】郵件觸發以及附件圖片預覽,配置摘要
- python 一鍵獲取郵件附件Python
- Mac郵件怎麼傳送超大附件Mac
- C# - MailSender 郵件傳送元件原始碼 (支援ESMTP, 附件) (轉)C#AI元件原始碼
- Python 傳送帶有附件的郵件Python
- python實現郵件接收、附件下載Python
- Java SendEmail實現帶附件的郵件功能JavaAI
- c# 傳送郵件程式碼,帶附件C#
- linux shell傳送帶附件的郵件Linux
- 利用SQL Server發郵件 (轉)SQLServer
- 【主機】sendEmail傳送帶有附件的郵件AI
- 什麼是郵件轉發(mailrelay)(轉)AI
- 郵件開發:接收解析郵件
- 【python】用SMTP模組傳送帶附件的郵件Python
- 用ASP發電子郵件 (轉)
- 什麼是郵件轉發(mail relay) (轉)AI
- 自動生成AWR報告並以郵件附件傳送
- 群發郵件
- shell發郵件
- oracle 發郵件Oracle
- iOS12系統應用傳送郵件中的附件iOS
- C#通過POP3獲取郵件(正文和附件)C#
- 如何讓郵附件上雲?分享企業網盤郵附件管理方案
- 如何使用ABAP傳送帶有PDF格式附件的電子郵件
- 郵件傳送,附件太大怎麼辦 → 那就用分卷壓縮吧
- Linux自動下傳送HTML格式並帶附件的郵件LinuxHTML
- 用Oracle發郵件Oracle
- 發郵件的例子
- linux 發郵件Linux
- 郵件開發:複雜郵件的一個示例
- javamail傳送郵件(轉)JavaAI
- Python2.7 smtplib傳送帶附件郵件報錯STARTTLS解PythonTLS
- 在Linux命令列傳送電子郵件附件的兩種方法Linux命令列
- 如何使用 ABAP 程式碼傳送帶有 PDF 附件的電子郵件
- 利用Jmail傳送帶附件的郵件時亂碼的解決方案AI
- python 發個郵件Python
- 郵件開發:DNS、JDNIDNS