0
votes

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); } }

2
Perhaps you like to explain how you are sending your email?Stephen C
Also, what are you attaching?Max Leske
We still need more details: do you have your own SMTP server? Or are you using a gmail acccount for instance to send your mail through?Max Leske
I am using Postfix mail agent.Praneeth.P
when I send only message(without attachments) then everthing goes fine. But if I include attachment then I could see only attachment but no message is seen.Praneeth.P

2 Answers

0
votes

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?

0
votes

Might help if you add

messageAttachmentBodyPart.setDisposition(Part.INLINE);