Download attachment of specific sheet name using java mail api

9 Views Asked by At

Following is the code which allows me to download the attachment from the Mail. But the data seems to be from the default sheet 1. And I'm looking for sheet 3 data.

                if (message.getContentType().contains("multipart")) 
                {
                    Multipart multiPart = (Multipart) message.getContent();
                    int numberOfParts = multiPart.getCount();
                    for (int partCount = 0; partCount < numberOfParts; partCount++)
                    {
                        MimeBodyPart part = (MimeBodyPart) multiPart
                                .getBodyPart(partCount);
                        if (Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition()))
                        {
                            // this part is attachment
                            String fileName = message.getSentDate() + " " + part.getFileName();
                            attachFiles += fileName + ",";
                            part.saveFile(saveDirectory + File.separator
                                    + fileName);
                            System.out.println(fileName);

                            message.setFlag(Flags.Flag.SEEN, true);
                            f = 0;

                        }
                  }
             }
0

There are 0 best solutions below