/** 372: * Return whether this helper is in multipart mode, 373: * i.e. whether it holds a multipart message. 374: * @see #MimeMessageHelper(MimeMessage, boolean) 375: */ 376: public final boolean isMultipart() { 377: return (this.rootMimeMultipart != null); 378: } 379: 380: /** 381: * Throw an IllegalStateException if this helper is not in multipart mode. 382: */ 383: private void checkMultipart() throws IllegalStateException { 384: if (!isMultipart()) { 385: throw new IllegalStateException("Not in multipart mode - " + 386: "create an appropriate MimeMessageHelper via a constructor that takes a 'multipart' flag " + 387: "if you need to set alternative texts or add inline elements or attachments."); 388: } 389: } 390:
372: * Return whether this helper is in multipart mode,
373: * i.e. whether it holds a multipart message.
374: * @see #MimeMessageHelper(MimeMessage, boolean)
375: */
376: public final boolean isMultipart() {
377: return (this.rootMimeMultipart != null);
378: }
379:
380: /**
381: * Throw an IllegalStateException if this helper is not in multipart mode.
382: */
383: private void checkMultipart() throws IllegalStateException {
384: if (!isMultipart()) {
385: throw new IllegalStateException("Not in multipart mode - " +
386: "create an appropriate MimeMessageHelper via a constructor that takes a 'multipart' flag " +
387: "if you need to set alternative texts or add inline elements or attachments.");
388: }
389: }
390:
参考用javamail发送带附件的邮件
JavaMail发送邮件(带附件)(
改为
MimeMessageHelper messageHelp = new MimeMessageHelper(message,true,encode);
就能了发了