List of usage examples for javax.mail Message setText
public void setText(String text) throws MessagingException;
From source file:com.sonicle.webtop.mail.Service.java
private SimpleMessage getForwardMsg(long id, Message msg, boolean richContent, String fromtitle, String totitle, String cctitle, String datetitle, String subjecttitle, boolean attached) { Message forward = new MimeMessage(mainAccount.getMailSession()); if (!attached) { try {/*from w ww . j a va 2 s.co m*/ StringBuffer htmlsb = new StringBuffer(); StringBuffer textsb = new StringBuffer(); boolean isHtml = appendReplyParts(msg, htmlsb, textsb, null); // Service.logger.debug("isHtml="+isHtml); // Service.logger.debug("richContent="+richContent); String html = "<HTML><BODY>" + htmlsb.toString() + "</BODY></HTML>"; if (!richContent) { forward.setText(getForwardBody(msg, textsb.toString(), SimpleMessage.FORMAT_TEXT, false, fromtitle, totitle, cctitle, datetitle, subjecttitle)); } else if (!isHtml) { forward.setText(getForwardBody(msg, textsb.toString(), SimpleMessage.FORMAT_PREFORMATTED, false, fromtitle, totitle, cctitle, datetitle, subjecttitle)); } else { forward.setText(MailUtils.removeMSWordShit(getForwardBody(msg, html, SimpleMessage.FORMAT_HTML, true, fromtitle, totitle, cctitle, datetitle, subjecttitle))); } } catch (Exception exc) { Service.logger.error("Exception", exc); } } try { String msgid = null; String vh[] = msg.getHeader("Message-ID"); if (vh != null) { msgid = vh[0]; } if (msgid != null) { forward.setHeader("Forwarded-From", msgid); } } catch (MessagingException exc) { Service.logger.error("Exception", exc); } SimpleMessage fwd = new SimpleMessage(id, forward); fwd.setTo(""); // Update appropriate subject // Fwd: subject try { String subject = msg.getSubject(); if (subject == null) { subject = ""; } if (!subject.toLowerCase().startsWith("fwd: ")) { fwd.setSubject("Fwd: " + subject); } else { fwd.setSubject(msg.getSubject()); } } catch (MessagingException e) { Service.logger.error("Exception", e); // Service.logger.debug("*** SimpleMessage: " +e); } return fwd; }
From source file:com.sonicle.webtop.mail.Service.java
private SimpleMessage getReplyMsg(int id, MailAccount account, Message msg, boolean replyAll, boolean fromSent, boolean richContent, String myemail, boolean includeOriginal, String fromtitle, String totitle, String cctitle, String datetitle, String subjecttitle) { try {//from w w w .j ava 2s . c om Message reply = reply(account, (MimeMessage) msg, replyAll, fromSent); removeDestination(reply, myemail); if (ss.getMessageReplyAllStripMyIdentities()) { for (Identity ident : mprofile.getIdentities()) { removeDestination(reply, ident.getEmail()); } } // Setup the message body // StringBuffer htmlsb = new StringBuffer(); StringBuffer textsb = new StringBuffer(); ArrayList<String> attnames = new ArrayList<String>(); if (includeOriginal) { boolean isHtml = appendReplyParts(msg, htmlsb, textsb, attnames); String html = "<HTML><BODY>" + htmlsb.toString() + "</BODY></HTML>"; String text = null; if (!richContent) { text = getReplyBody(msg, textsb.toString(), SimpleMessage.FORMAT_TEXT, false, fromtitle, totitle, cctitle, datetitle, subjecttitle, attnames); } else if (!isHtml) { text = getReplyBody(msg, textsb.toString(), SimpleMessage.FORMAT_PREFORMATTED, false, fromtitle, totitle, cctitle, datetitle, subjecttitle, attnames); } else { text = getReplyBody(msg, html, SimpleMessage.FORMAT_HTML, true, fromtitle, totitle, cctitle, datetitle, subjecttitle, attnames); } reply.setText(MailUtils.removeMSWordShit(text)); } else { reply.setText(""); } return new SimpleMessage(id, reply); } catch (MessagingException e) { Service.logger.error("Exception", e); // Service.logger.debug("*** SimpleMessage: " + e); return null; } catch (IOException e) { Service.logger.error("Exception", e); // Service.logger.debug("*** SimpleMessage: " + e); return null; } }