试试看: 15:if (ct.match("text/plain")) 换成:15: if (ct.match("text/plain;charset=gb2312")) 我看了sina的我的邮件的编码. 以下是我的一封邮件内容. Subject: attach test3 Date: Sun Nov 12 08:35:28 2000 X-Mailer: SinaMail 3.0Beta (FireToad) X-Priority: 3 Content-Type: multipart/mixed; boundary="----------97401812817428SINAEMAIL---"This is a multi-part message in MIME format.------------97401812817428SINAEMAIL--- Content-Disposition: inline Content-Transfer-Encoding: binary <font color=red>Content-Type: text/plain;charset="gb2312"</font>KKK ______________________________________ .
又或者换成 ct.match("text/*") 这样"text/html","text/plain"都能返回true.以下是j2ee文档: public boolean match(java.lang.String s)Match with the specified content-type string. This method compares only the primaryType and subType . The parameters of both operands are ignored.For example, this method will return true when comparing the ContentType for "text/plain" with "text/plain; charset=foobar". If the subType of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will return true when comparing the ContentType for "text/plain" with "text/*"附:pop3 RFC1939
谢谢cming,但是问题仍然没有解决。
isMimeType public boolean isMimeType(java.lang.String mimeType) throws MessagingException Is this Part of the specified MIME type? This method compares only the primaryType and subType. The parameters of the content types are ignored. For example, this method will return true when comparing a Part of content type "text/plain" with "text/plain; charset=foobar". If the subType of mimeType is the special character '*', then the subtype is ignored during the comparison.这是JAVADOC,明白了吧。如果是MIMETYPE,那么content type是被忽略的
难道是html的?
如果将15行换成 if (ct.match("text/html")) 依旧没有任何改变。
15:if (ct.match("text/plain"))
换成:15: if (ct.match("text/plain;charset=gb2312")) 我看了sina的我的邮件的编码.
以下是我的一封邮件内容.
Subject: attach test3
Date: Sun Nov 12 08:35:28 2000
X-Mailer: SinaMail 3.0Beta (FireToad)
X-Priority: 3
Content-Type: multipart/mixed;
boundary="----------97401812817428SINAEMAIL---"This is a multi-part message in MIME format.------------97401812817428SINAEMAIL---
Content-Disposition: inline
Content-Transfer-Encoding: binary
<font color=red>Content-Type: text/plain;charset="gb2312"</font>KKK
______________________________________
.
ct.match("text/*")
这样"text/html","text/plain"都能返回true.以下是j2ee文档:
public boolean match(java.lang.String s)Match with the specified content-type string. This method compares only the primaryType and subType . The parameters of both operands are ignored.For example, this method will return true when comparing the ContentType for "text/plain" with "text/plain; charset=foobar". If the subType of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will return true when comparing the ContentType for "text/plain" with "text/*"附:pop3 RFC1939
public boolean isMimeType(java.lang.String mimeType)
throws MessagingException
Is this Part of the specified MIME type? This method compares only the primaryType and subType. The parameters of the content types are ignored. For example, this method will return true when comparing a Part of content
type "text/plain" with "text/plain; charset=foobar". If the subType of mimeType is the special character '*', then the subtype is ignored during the comparison.这是JAVADOC,明白了吧。如果是MIMETYPE,那么content type是被忽略的
我不太理解MIMEtype 和 content type得关系。这段文档,太隐晦了。我不太明白该怎么做。
但是我看了javamail得demo。这部分问题的处理好象和我付的原代码一样。
你的coding能不能贴出来,大家分享分享!
《用javamail显示复合邮件的内容的亲身体会》
文档中心,这是我的处女作。不妥之处请指教。