在用javamail编写邮件发送系统时,调试阶段没有任何问题,但在打成jar包的时候运行故障如下:
no object DCH for MIME type
后面我记不清了,意思好像是不支持MIME type=gbk或utf-8,废话少说,解决方法如下:
事实上这个是邮件发送时验证组件设置不当引起的,这个组件配置方法如下
(http://java./j2ee/1.4/docs/api/javax/activation/MailcapCommandMap.html)
The MailcapCommandMap looks in various places in the user’s system for mailcap file entries. When requests are made to search for commands in the MailcapCommandMap, it searches mailcap files in the following order:
1) Programatically added entries to the MailcapCommandMap instance. 2) The file .mailcap in the user’s home directory. 3) The file /lib/mailcap. 4) The file or resources named META-INF/mailcap. 5) The file or resource named META-INF/mailcap.default (usually found only in the activation.jar file).
我选用了第四种方法,在生成的Jar文件中加入了 META-INF/mailcap.
# # This is a very simple ''mailcap'' file # image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer text/*;; x-java-view=com.sun.activation.viewers.TextViewer text/*;; x-java-edit=com.sun.activation.viewers.TextEditor text/html;; x-java-content-handler=com.sun.mail.handlers.text_html text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822
|