【发布时间】:2011-03-23 14:20:40
【问题描述】:
为什么我将邮件内容发送到 Hotmail 帐户时会作为附件发送?
当我向 Hotmail 帐户发送邮件时,邮件正文作为附件发送。但是当发送到 yahoomail、gmail 等其他帐户时,它不会产生任何问题。
我想知道为什么我在使用 Hotmail 帐户时遇到问题。
请给我一个解决方案。
MimeMessage msg = createMimeMessage(sender, emsg,session,mail.companyName); Transport.send(msg);
Multipart multipart = new MimeMultipart();
//这是模板附件部分
if (emsg.getAttachment() != null) {
for(文件文件:emsg.getAttachment()){
MimeBodyPart messageAttachmentBodyPart = new MimeBodyPart(); messageAttachmentBodyPart = new MimeBodyPart();
数据源源 = new FileDataSource(file);
messageAttachmentBodyPart.setDataHandler(new DataHandler(source)); messageAttachmentBodyPart.setFileName(file.getName()); multipart.addBodyPart(messageAttachmentBodyPart); } }
【问题讨论】:
-
也许您想解释一下如何发送您的电子邮件?
-
另外,你要附加什么?
-
我们还需要更多细节:您有自己的 SMTP 服务器吗?或者您是否使用 gmail 帐户发送邮件?
-
我正在使用 Postfix 邮件代理。
-
当我只发送消息(不带附件)时,一切都很好。但如果我包含附件,那么我只能看到附件,但看不到任何消息。
标签: java