1 year ago

#316175

test-img

dbuergi

Having trouble embedding base64 encoded png file into outlook signature via html

I'm having trouble embedding a base64 encoded png file into outlook signature via java/html. It recently stopped working the way it used to and I think some Windows update is the reason as to why it stopped working properly.

The picture's not properly embedded like shown here.

This method is writing the html content:

    private void changeHTMLContent(String HTMLFileName) throws FileNotFoundException, IOException, SQLException {
    getHTMLContent(HTMLFileName);
    String fileLang = HTMLFileName.substring(11, 13).toUpperCase();
    langCfg = cfgReader.getLanguageConfig(fileLang);

    htmlString = htmlString.replace("[NAME]", uDataSet.getPersonalName());
    htmlString = htmlString.replace("[VORNAME]", uDataSet.getPersonalFirstName());
    htmlString = htmlString.replace("[FUNKTION]", uDataSet.getPersonalFunction());
    htmlString = htmlString.replace("[TELEFON]", langCfg.get("tel") + " " + uDataSet.getTelefonNumber());
    if (uDataSet.getTelefonMobil().length() != 0) {
        htmlString = htmlString.replace("[MOBILTELEFON]", langCfg.get("mobile") + " " + uDataSet.getTelefonMobil());
    } else {
        htmlString = htmlString.replace("[MOBILTELEFON]<br>", "\r");
    }
    if (uDataSet.getTelefonFax().length() != 0) {
        htmlString = htmlString.replace("[FAX]", langCfg.get("fax") + " " + uDataSet.getTelefonFax());
    } else {
        htmlString = htmlString.replace("[FAX]<br>", "\r");
    }
    htmlString = htmlString.replace("[EMAILT]", langCfg.get("email") + " ");
    htmlString = htmlString.replace("[EMAIL]", uDataSet.getPersonalEmail());
    htmlString = htmlString.replace("[EMAIL1]", uDataSet.getPersonalEmail());
    htmlString = htmlString.replace("[LOGO]", "<img border=0 width=180 height=70 src=" + "\"data:image/png;base64, " + imgLogoStr + "\">");
    if (arguments.get("name") != null) {
        String logoFile = System.getenv(cfgOutFilePath.get("userProfile")) + cfgOutFilePath.get("logofilepath") + arguments.get("name") + ".jpg";
        BufferedImage image = ImageIO.read(new File(logoFile));
        int height = image.getHeight();
        int width = image.getWidth();
        String imageString = encodeToString(image, "jpg");
        String HTMLLogoElement = "<tr>\n"
                + " <td width=" + width + " valign=top style='width:" + width + "pt;padding:0.5cm 5.4pt 0cm 5.4pt; border:none;'>\n"
                + "     <p class=MsoNormal style='text-autospace:none'><b><i><span style='font-size:\n"
                + "       10.0pt;font-family:Arial'><img border=0 width=" + width + " height=" + height + "\n"
                + "       src=\"data:image/png;base64," + imageString + "\"></span></i></b></p>\n"
                + " </td>\n"
                + " </tr>";
        htmlString = htmlString.replace("[ADDITIONALLOGO]", HTMLLogoElement);
    } else {
        htmlString = htmlString.replace("[ADDITIONALLOGO]", "\r");
    }

}

Here's the html content:

  <td width=318 valign=top style='width:238.65pt;border:none;border-top:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'><br>
  <p class=MsoNormal style='text-autospace:none'><b><i><span style='font-size:
  10.0pt;font-family:Arial'><img border=0 width=180 height=70 src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALQAAABGCAYAAABll74gAAAKXklEQVR42u1dbZaqMAx1P/50LW7BdbCNboG18Lfr4U3RYEjz1YKO40vO8YwjUEJ7e5smaTnNISFfJKeogpAAdEhIADokJAAdEhKADglAh4QEoENCAtAhIQHokJAAdEgAOiQkAB3yCzLlab6cL/fP9edzusxpTAHogMYfBfQ4zafTafO5DbcA9P/2wN/CYoWhK0BfA9Cn/wXEZWiGhv+WZwqG/g8BTRv9WwDNmhzB0AHov87SBdjF/IgJYQA6JAAdgA75IkBPGX167D5Sxq7r3wzoZXjPk+hxKEM/mABHeDCOKusoPfG1n2zemK17G39Owp+B/B3tm9zKBIZcg8szleTuq9yf8wBIn/WaIbHH8O900lW8ClrZUsOXcth7CXoXHVxeDmFSaOkpdVRJV+sZT9eJx8xR//+UfxM65MkEElco811iXA6A3k5RyvTcu/zF9+c8ACagGYD8cJLoFiuROU/5HMg4gHEdaqMLaUBvYMVbDxwwsauz5VqrrY44nnIjQy+sOjhupoByZWaH0lyPk67b6Aa/D9M+hnZcA0xpsZYFRosxLV3BBLA6T6uevaMcvfYVAKbfUytDc4XgoYkDKmVpDbScspaZopo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r4vAHkESTSzirsW6gN04uobtw83yuH6lr5T7GlYaQI03rMY3i2tVRRthOXhzqeNLV4Nrz/nQiVgswU/HL5WY038zutleH2YSkUH7v7eiQlEEeH513A5avxyDDcwsBk9D7OllDK6dBxrBf2jvoBNqclAOxOuEww6je0oYCnBceSCy7wtdaYTF96i2JoAu+rFehiJBaQJA8fi0ODc7pYQRtV6K2U4+d0ll7VMCNdC+ZR5LEDfbXDbtqbAwH/h+ureeTsc49GoXIOHVpGJHCYH1pfWydIW2SgnMwx93gKaywPhOjWHD24E07wtm3rJjQwNcXuWtdFO9lziNwV01dMFswH3XG5yQod5albcz7uwo4DWAbnKgcqzWAu/HwWejTIZNZmk8qRXSvS4vGDSKD03NsPEedNcMzQ2qTggSqOUytDc/GyU6wVyZpoA7Zn9Q4VjZr0DemInYvQ3uA5PRiyTY52sjYlt9HVomp9DGa5AWomW2w5MCTw0cvY9/Ablcs+LzQr67JUHBcqRGu5h+qwJVQ+vyYb9Mv8cWF+4Pz4Guld1PfBEVECO63udV1xthqbYwe0NIzpXv2KuuuR71vYug8qhE6fpYadxqy+0JPe7SwbZo+XeWfbjLvb86SLmG2MPCTVP8FAP8wLLV7qaW2f5bVHYhUafl+qPn51jH2uBATzjmj13rTP9tPxm+gybV9cN9avrFsA+OrS1CTwuG+ZHku+5RUdvvUToO+SrJAAdEoAOCQlAh4QEoENCAtAhAeiQkAB0SEgAOiTklfIPyzXXIYqQ110AAAAASUVORK5CYII="></span></i></b></p>
  </td>

Any help fixing this would be appreciated.

java

html

base64

png

signature

0 Answers

Your Answer

Accepted video resources