Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 79698 invoked from network); 17 Mar 2005 20:18:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 17 Mar 2005 20:18:53 -0000 Received: (qmail 2248 invoked by uid 500); 17 Mar 2005 20:18:47 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 2162 invoked by uid 500); 17 Mar 2005 20:18:46 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 2147 invoked by uid 99); 17 Mar 2005 20:18:46 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from ajax-1.apache.org (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 17 Mar 2005 12:18:46 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (8.12.11/8.12.11) with ESMTP id j2HKIhmD014211 for ; Thu, 17 Mar 2005 21:18:43 +0100 Received: (from nobody@localhost) by ajax.apache.org (8.12.11/8.12.11/Submit) id j2HKIhgZ014209; Thu, 17 Mar 2005 21:18:43 +0100 Date: Thu, 17 Mar 2005 21:18:43 +0100 Message-Id: <200503172018.j2HKIhgZ014209@ajax.apache.org> From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Subject: DO NOT REPLY [Bug 34056] - Improve MultiPartEmail to ease extending X-Bugzilla-Reason: AssignedTo X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=34056 ------- Additional Comments From troy_poppe@yahoo.com 2005-03-17 21:18 ------- (From update of attachment 14506) Index: c:/projects3.0/commons-email/src/java/org/apache/commons/mail/MultiPartEmail.ja va =================================================================== --- c:/projects3.0/commons-email/src/java/org/apache/commons/mail/MultiPartEmail.ja va (revision 157757) +++ c:/projects3.0/commons-email/src/java/org/apache/commons/mail/MultiPartEmail.ja va (working copy) @@ -19,13 +19,16 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; + import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; import javax.activation.URLDataSource; +import javax.mail.BodyPart; import javax.mail.MessagingException; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; + import org.apache.commons.lang.StringUtils; /** @@ -52,7 +55,7 @@ private MimeMultipart container = null; /** The message container. */ - private MimeBodyPart primaryBodyPart = null; + private BodyPart primaryBodyPart = null; /** The MIME subtype. */ private String subType = null; @@ -92,7 +95,7 @@ public Email addPart(String content, String contentType) throws EmailException { - MimeBodyPart bodyPart = new MimeBodyPart(); + BodyPart bodyPart = createBodyPart(); try { bodyPart.setContent(content, contentType); @@ -115,7 +118,7 @@ */ public Email addPart(MimeMultipart multipart) throws EmailException { - MimeBodyPart bodyPart = new MimeBodyPart(); + BodyPart bodyPart = createBodyPart(); try { bodyPart.setContent(multipart); getContainer().addBodyPart(bodyPart); @@ -140,7 +143,7 @@ throw new IllegalStateException("Already initialized"); } - container = new MimeMultipart(); + container = createMimeMultipart(); super.setContent(container); initialized = true; @@ -164,7 +167,9 @@ try { if (StringUtils.isNotEmpty(charset)) { - getPrimaryBodyPart().setText(msg, charset); +// BROKEN! +// getPrimaryBodyPart().setText(msg, charset); + getPrimaryBodyPart().setText(msg); } else { @@ -192,7 +197,7 @@ // the content for the main body part was actually set. If not, // an IOException will be thrown during super.send(). - MimeBodyPart body = this.getPrimaryBodyPart(); + BodyPart body = this.getPrimaryBodyPart(); Object content = null; try { @@ -380,7 +385,7 @@ { name = ds.getName(); } - MimeBodyPart mbp = new MimeBodyPart(); + BodyPart mbp = createBodyPart(); try { getContainer().addBodyPart(mbp); @@ -392,7 +397,7 @@ catch (MessagingException me){ throw new EmailException(me); } - this.boolHasAttachments = true; + setBoolHasAttachments(true); return this; } @@ -404,7 +409,7 @@ * @throws EmailException see javax.mail.internet.MimeBodyPart * for defintions */ - protected MimeBodyPart getPrimaryBodyPart() throws MessagingException + protected BodyPart getPrimaryBodyPart() throws MessagingException { if (!initialized) { @@ -414,7 +419,7 @@ // Add the first body part to the message. The fist body part must be if (this.primaryBodyPart == null) { - primaryBodyPart = new MimeBodyPart(); + primaryBodyPart = createBodyPart(); getContainer().addBodyPart(primaryBodyPart); } @@ -437,6 +442,23 @@ return container; } + /** + * + * @return + */ + protected boolean isInitialized() + { + return initialized; + } + + /** + * + * @param b + */ + protected void setIsInitialized(boolean b) + { + initialized = b; + } /** * @return boolHasAttachments @@ -453,5 +475,24 @@ { boolHasAttachments = b; } + + /** + * + * @return + */ + protected BodyPart createBodyPart() + { + BodyPart bp = new MimeBodyPart(); + return bp; + } + /** + * + * @return + */ + public MimeMultipart createMimeMultipart() + { + MimeMultipart mmp = new MimeMultipart(); + return mmp; + } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org