/** * Get an attachment's file name * * @param partIndex * @return * @throws PackageException */ @PublicAtsApi public String getAttachmentFileName( int partIndex ) throws PackageException { // first check if there is part at this position at all if (partIndex >= attachmentPartIndices.size()) { throw new NoSuchMimePartException("No attachment at position '" + partIndex + "'"); } try { MimePart part = getPart(attachmentPartIndices.get(partIndex)); // get the attachment file name String fileName = part.getFileName(); if (fileName == null) { throw new PackageException("Could not determine file name for attachment at position " + partIndex); } return fileName; } catch (MessagingException me) { throw new PackageException(me); } }