开发者

why mail content is sent as attachment when I send it to Hotmail account?

why mail content is sent as attachment when I send it to Hotmail account?

When I send mail to a Hotmail account the body of the mail is sent as attachment. But when sent to other accounts like yahoomail, gmail it is not creating any problem.

I want to know开发者_JAVA技巧 why I am getting problem with Hotmail accounts.

Please give me a solution for this.

MimeMessage msg = createMimeMessage(sender, emsg,session,mail.companyName); Transport.send(msg);

Multipart multipart = new MimeMultipart();

// This is the template Attachment part

if (emsg.getAttachment() != null) {

for (File file : emsg.getAttachment()) {

MimeBodyPart messageAttachmentBodyPart = new MimeBodyPart(); messageAttachmentBodyPart = new MimeBodyPart();

DataSource source = new FileDataSource(file);

messageAttachmentBodyPart.setDataHandler(new DataHandler(source)); messageAttachmentBodyPart.setFileName(file.getName()); multipart.addBodyPart(messageAttachmentBodyPart); } }


Right. So, what happens if you send a file from a gmail account to a hotmail account, does it get attached? Or is it displayed just as you want? My guess is that attaching the file is a security measure to prevent malicious code from being activated on display. This mechanism might also be selective, meaning that it depends on the sender (an interesting post to read on this matter is this one).

Another thought: why is that a problem anyway?


Might help if you add

messageAttachmentBodyPart.setDisposition(Part.INLINE);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜