List of usage examples for javax.mail BodyPart getParent
public Multipart getParent()
Multipart
object, or null
if not known. From source file:org.mxhero.engine.plugin.attachmentlink.alcommand.internal.domain.Message.java
public void removeAll(Part part, BodyPart notDelete) throws MessagingException, IOException { if (isAttach(part)) { if (part != notDelete) { BodyPart multi = (BodyPart) part; Multipart parent = multi.getParent(); parent.removeBodyPart(multi); }//from w w w. ja va 2 s . c o m } else if (part.isMimeType(MULTIPART_TYPE)) { Multipart mp = (Multipart) part.getContent(); List<BodyPart> toRemove = new ArrayList<BodyPart>(); for (int i = 0; i < mp.getCount(); i++) { BodyPart bodyPart = mp.getBodyPart(i); if (removePart(bodyPart, notDelete)) { toRemove.add(bodyPart); } else { removeAll(bodyPart, notDelete); } } for (BodyPart bp : toRemove) mp.removeBodyPart(bp); } }