[英]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? 为什么将邮件内容发送到Hotmail帐户时将其作为附件发送?
When I send mail to a Hotmail account the body of the mail is sent as attachment. 当我将邮件发送到Hotmail帐户时,邮件正文将作为附件发送。 But when sent to other accounts like yahoomail, gmail it is not creating any problem.
但是,当发送到其他帐户(例如yahoomail,gmail)时,它不会造成任何问题。
I want to know why I am getting problem with Hotmail accounts. 我想知道为什么Hotmail帐户出现问题。
Please give me a solution for this. 请给我一个解决方案。
MimeMessage msg = createMimeMessage(sender, emsg,session,mail.companyName); MimeMessage msg = createMimeMessage(sender,emsg,session,mail.companyName); Transport.send(msg);
Transport.send(msg);
Multipart multipart = new MimeMultipart(); Multipart multipart = new MimeMultipart();
// This is the template Attachment part //这是模板附件部分
if (emsg.getAttachment() != null) { 如果(emsg.getAttachment()!= null){
for (File file : emsg.getAttachment()) { 对于(文件文件:emsg.getAttachment()){
MimeBodyPart messageAttachmentBodyPart = new MimeBodyPart(); MimeBodyPart messageAttachmentBodyPart =新的MimeBodyPart(); messageAttachmentBodyPart = new MimeBodyPart();
messageAttachmentBodyPart =新的MimeBodyPart();
DataSource source = new FileDataSource(file); DataSource源=新的FileDataSource(file);
messageAttachmentBodyPart.setDataHandler(new DataHandler(source)); messageAttachmentBodyPart.setDataHandler(new DataHandler(source)); messageAttachmentBodyPart.setFileName(file.getName());
messageAttachmentBodyPart.setFileName(file.getName()); multipart.addBodyPart(messageAttachmentBodyPart);
multipart.addBodyPart(messageAttachmentBodyPart); } }
}}
Right. 对。 So, what happens if you send a file from a gmail account to a hotmail account, does it get attached?
因此,如果您将文件从gmail帐户发送到hotmail帐户,会出现附件怎么办? 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 ).
这种机制也可能是选择性的,这意味着它取决于发件人(有关此问题的一个有趣的帖子就是this )。
Another thought: why is that a problem anyway? 另一个想法:为什么这仍然是一个问题?
如果您添加,可能会有所帮助
messageAttachmentBodyPart.setDisposition(Part.INLINE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.