如下图所示:
我用的是HtmlEditorKit而我用getText返回的Html是这样的text == <html>
<head> </head>
<body>
<p style="margin-top: 0">
<img src="I:/my doc/work/email/test.gif">
</p>
</body>
</html>插入图片的代码如下: selectedFile = chooser.getSelectedFile().getCanonicalFile();
//添加图片到jTextPane修改Doc
String img = selectedFile.getCanonicalPath();
if(img == null || (img != null && img.trim().length() == 0))
return ;
HTMLEditorKit kit = (HTMLEditorKit) getJTextPane().getEditorKit();
jTextPane.setEditorKit(kit);
img = img.replaceAll("\\\\", "/");
logger.info("img path ==" + img);
kit.insertHTML((HTMLDocument) jTextPane.getDocument(), jTextPane.getCaretPosition(), "<img src=\"" + img+ "\""+">",0,0,HTML.Tag.IMG);为什么会只出现图片的图标呢?而且好像是不能载入的那种图标
我用的是HtmlEditorKit而我用getText返回的Html是这样的text == <html>
<head> </head>
<body>
<p style="margin-top: 0">
<img src="I:/my doc/work/email/test.gif">
</p>
</body>
</html>插入图片的代码如下: selectedFile = chooser.getSelectedFile().getCanonicalFile();
//添加图片到jTextPane修改Doc
String img = selectedFile.getCanonicalPath();
if(img == null || (img != null && img.trim().length() == 0))
return ;
HTMLEditorKit kit = (HTMLEditorKit) getJTextPane().getEditorKit();
jTextPane.setEditorKit(kit);
img = img.replaceAll("\\\\", "/");
logger.info("img path ==" + img);
kit.insertHTML((HTMLDocument) jTextPane.getDocument(), jTextPane.getCaretPosition(), "<img src=\"" + img+ "\""+">",0,0,HTML.Tag.IMG);为什么会只出现图片的图标呢?而且好像是不能载入的那种图标
发送邮件后生成的eml文件在outlook也能打开。
用outlook打开的话这个文件正常的不得了。
是本地还是web网络上?
<head> </head>
<body>
<p style="margin-top: 0">
<img src="I:/my doc/work/email/test.gif">
</p>
</body>
</html> 这个html是没啥问题
其他的就不太懂了 呵呵
标准的格式应该是 file:///i:/my docxxxxxxooooo在oe和ie和firefox下面少了file:///也能解析出来,但是JTextPane不行。
呵呵