2016-04-28 7 views
1

ich auf eine Anwendung arbeite, die jedoch von MIMEEntity, E-Mail-Inhalte anzuzeigen, merke ich, wenn es Inline-Bilder in der E-Mail ist, ersetzen sie das Bild mit Bild-Platzhalter enter image description hereXPages: Anzeige E-Mail-Inhalte mit Inline-Bilder

und wann immer es ist ein leerer E-Mail-Inhalte mit pdf attachement, erhalte ich eine Zeichenfolge wie:

%PDF-1.3 
%ÔÒ¤Ë 
%RSTXPDF3 Parameters: ERSXh 
2 0 obj 
<< 
/Type /FontDescriptor 
/Ascent 720 
/CapHeight 660 
/Descent -270 
/Flags 32 
/FontBBox [-177 -269 1123 866] 
/FontName /Helvetica 
/ItalicAngle 0 
/StemV 105 
>> 
endobj 
3 0 obj 
/WinAnsiEncoding 
endobj 
4 0 obj 
<< 
%Devtype PDF1  Font HELVE normal Lang DE 
/Type /Font 
/Subtype /Type1 
/BaseFont /Helvetica 
/Name /F001 
/Encoding 3 0 R 
/FirstChar 32 
/LastChar 255 
%Charwidth values from PDF1 HELVE 080 normal 
/Widths 
[ 278 275 356 556 556 888 669 225 331 331 388 581 275 331 275 275 556 556 556 556 556 556 556 556 556 556 275 275 581 581 581 556 1013 669 669 725 725 669 613 775 725 275 500 669 556 831 725 775 669 775 725 669 613 725 669 944 669 669 613 275 275 275 469 
556 225 556 556 500 556 556 275 556 556 225 225 500 225 831 556 556 556 556 331 500 275 556 500 725 500 500 500 331 263 331 581 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 331 556 556 556 556 263 556 331 738 369 556 581 0 738 
331 331 581 331 331 331 500 538 275 331 331 363 556 831 831 831 613 669 669 669 669 669 669 1000 725 669 669 669 669 275 275 275 275 725 725 775 775 775 775 775 581 775 725 725 725 725 669 669 613 556 556 556 556 556 556 888 500 556 556 556 556 275 275 
275 275 556 556 556 556 556 556 556 581 613 556 556 556 556 500 556 500] 
/FontDescriptor 2 0 R 
>> 
endobj 
5 0 obj 
<< 
/Type /FontDescriptor 
/Ascent 720... 

Unten ist mein Code:

public static String getEmailContent(MIMEEntity mime) throws NotesException { 
     String text = null; 
     String html = null; 
     if (mime != null) { 
      if ("multipart".equalsIgnoreCase(mime.getContentType())) { 
       MIMEEntity child = mime.getFirstChildEntity(); 
       while (child != null) { 
        String mimeType = child.getContentType() + "/" + child.getContentSubType(); 
        child.decodeContent(); 
        String contentDecoded = child.getContentAsText(); 
        if ("text/html".equals(mimeType)) { 
         if (html == null) {       
          html = contentDecoded;      
         } 
        } else if ("text/plain".equals(mimeType)) { 
         if (text == null) { 
          text = "<pre>" + contentDecoded + "</pre>"; 
         } 
        } 
        // get next Child-Element 
        MIMEEntity tmpChild = child.getFirstChildEntity(); 
        if (tmpChild == null) { 
         tmpChild = child.getNextSibling(); 
         if (tmpChild == null) { 
          tmpChild = child.getParentEntity(); 
          if (tmpChild != null) 
           tmpChild = tmpChild.getNextSibling();      } 
        } 
        child = tmpChild; 
       } 
      } else if ("text".equalsIgnoreCase(mime.getContentType())) { 
       String subType = mime.getContentSubType(); 
       mime.decodeContent(); 
       String contentDecoded = mime.getContentAsText(); 
       if ("html".equalsIgnoreCase(subType)) { 
        if (html == null) { 
         html = contentDecoded; 
        } 
       } else if ("plain".equalsIgnoreCase(mime.getContentSubType())) { 
        if (text == null) { 
         text = "<pre>" + contentDecoded + "</pre>"; 
        } 
       } 
      } else { 
       mime.decodeContent(); 
       text = "<pre>" + mime.getContentAsText() + "</pre>"; 
      } 
     } 
     if (html != null) { 

      return html; 
     } else { 

      return text; 
     } 
    } 

Ich weiß nicht, was ich falsch mache, ich brauche etwas Hilfe

Antwort

1

Dies ist ein ziemlich tiefes Kaninchen Loch, denke ich. Wenn Sie Bilder anzeigen möchten, die aus dem MIME-Baum stammen, können Sie die referenzierten Anhänge per CID extrahieren und in den ursprünglichen HTML-Code einfügen, entweder als data URIs oder als Verweis auf ein anderes Skript, das auf dem Bildschirm angezeigt wird die Bilder.

Sie können am besten mit IBM DominoDocument Klasse nutzen. Wenn Sie eine xp:dominoDocument Datenquelle verwenden, um damit zu beginnen, sind Sie fertig; Andernfalls können Sie die Methode DominoDocument.wrap verwenden, um sie manuell zu umbrechen (siehe the Javadoc). Sobald Sie das haben, glaube ich, dass Sie getValue("someRtField").toString() verwenden können, um eine nützliche HTML-Darstellung unabhängig von dem ursprünglichen Format (CD oder MIME) zu erhalten, das IBM Servlets verwendet, um eingebettete Bilder anzuzeigen.

Ich denke, Sie werden noch Befestigungs Referenzen verlieren, aber man konnte entweder eine xp:fileDownload Kontrolle oder getAttachmentList("someRtField") auf das DominoDocument Objekt (wenn die Ziel-Präsentation in einem XPage ist).