Below is the code snippet i am trying
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
try {
MimeMessage mimeMessage = new MimeMessage(session, mailFileInputStream);
Object content=mimeMessage.getContent();
BodyPart messagePart = null;
int count = ((Multipart) content).getCount();
//count is always =2
messagePart = ((Multipart) content).getBodyPart(0);
I tried with messagePart = ((Multipart)content).getBodyPart(1); as well because count is 2 but not able to get attachement
below is the snippet of mail coming from O365 and i am passin git here as file object.
due to securtiy reason i can not paste all here.
Some text above here
MIME-Version: 1.0
----boundary_1_768a7606-5356-4f2e-9cb9-4bcd2d468832
Content-Type: multipart/alternative;
boundary="--boundary_0_2af5fb85-1e87-4c34-86ad-3a52ef763b25"
----boundary_0_2af5fb85-1e87-4c34-86ad-3a52ef763b25
Content-Type: text/plain; charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit
-- Sent by an external sender --
----boundary_0_2af5fb85-1e87-4c34-86ad-3a52ef763b25--
----boundary_1_768a7606-5356-4f2e-9cb9-4bcd2d468832
Content-Type: multipart/mixed;
boundary="--boundary_2_69f808df-a154-4593-ba90-6c3a570d77c8"
----boundary_2_69f808df-a154-4593-ba90-6c3a570d77c8
Content-Type: application/octet-stream; name="attachment.csv"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
encryted code is comes here
----boundary_2_69f808df-a154-4593-ba90-6c3a570d77c8--
----boundary_1_768a7606-5356-4f2e-9cb9-4bcd2d468832--
I need to extract the attachment.csv file