How to get the value of the cid: from an image in the body of the email

0

Good morning,

I need to get the value of cid: from the images contained in the body of the email at the time of reading to be able to replace the value of cid: by the base64 of the image, but I can not get that value, does anyone have any tips? / p>

            try {
           MimeMultipart multipart = (MimeMultipart) msg.getDataHandler().getContent();
           int temp = 0, temp2 = 0;
           for (int k = 0; k < multipart.getCount(); k++) {
              MimeBodyPart bodyPart = (MimeBodyPart) multipart.getBodyPart(k);
              String splited[] = new String[15];
              splited = bodyPart.getContentType().split(" ");

              if (!splited[0].equals("text/plain;") && !splited[0].equals("text/html;")) {
                 MimeBodyPart part = bodyPart;
                 MimeMultipart p = (MimeMultipart) part.getDataHandler().getContent();
                 int count = 0;
                 for (int i = 0; i < p.getCount(); i++) {
                    String mimeSplited[] = new String[15];
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
                    Base64 decoder64 = new Base64();
                    StringBuilder s = new StringBuilder(eMail.getCorpoEmail());

                    System.out.println("CID NAME" + i + " :" + p.getBodyPart(i).getFileName());
                    System.out.println("CID TYPE" + i + " :" + p.getBodyPart(i).getContentType());

                    if (i != p.getCount() - 1) {
                       p.getBodyPart(i + 1).getDataHandler().writeTo(bos);
                       mimeSplited = p.getBodyPart(i + 1).getContentType().split(" ");
                       s.insert(s.indexOf(":part" + (i + 1)) - 3, "data:" + mimeSplited[0] + " base64," + decoder64.encodeToString(bos.toByteArray()));
                    } else {
                       p.getBodyPart(i).getDataHandler().writeTo(bos);
                       mimeSplited = p.getBodyPart(i).getContentType().split(" ");
                       s.insert(s.indexOf(":part" + i) - 3, "data:" + mimeSplited[0] + " base64," + decoder64.encodeToString(bos.toByteArray()));

                    }
                    eMail.setCorpoEmail(s.toString());
                 }
              } else {
              }

My code so far.

    
asked by anonymous 07.03.2018 / 14:43

0 answers