Java类型不匹配:无法从MimeBodyPart转换为BodyPart [英] Java Type mismatch: cannot convert from MimeBodyPart to BodyPart
本文介绍了Java类型不匹配:无法从MimeBodyPart转换为BodyPart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试发送带有附件的电子邮件。在此输入链接描述但是我的eclipse allway给了我这个错误:
i'm trying to send email with attachment as it said here enter link description here but my eclipse allways gives me this error:
类型不匹配:无法从MimeBodyPart转换为BodyPart
和
类型不匹配:无法从MimeMultipart转换为多部分
这是我的导入库:
import javax.mail.BodyPart;
import javax.mail.Multipart;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart;
这是出现错误的代码:
BodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
我做错了什么?
感谢您的帮助!
推荐答案
您需要 MimeMultipart
和 MimeBodyPart
从 javax.mail.internet
包中。请参阅Javadoc 此处和此处。
You want MimeMultipart
and MimeBodyPart
from the javax.mail.internet
package instead. See the Javadoc here and here.
您与SOAP消息传递的东西有关的类。
The classes you have relate to SOAP messaging stuff.
这篇关于Java类型不匹配:无法从MimeBodyPart转换为BodyPart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文