简体   繁体   中英

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 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?

如果您添加,可能会有所帮助

messageAttachmentBodyPart.setDisposition(Part.INLINE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM