简体   繁体   English

为什么将邮件内容发送到Hotmail帐户时将其作为附件发送?

[英]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.

相关问题 当我使用javamail将回复邮件发送到Outlook帐户时,为什么将回复邮件作为附件发送? - why the reply mail is sent as attachment when I send it to outlook account using javamail? 我正在尝试发送带有附件的电子邮件,但是当我单击“发送”时,邮件已发送但没有附件(无任何意图) - i am trying to send email with attachment , but when i click send the mail is sent but without attachment(without any intent)) 为什么分段/混合Java邮件内容在Outlook中作为附件发送? - Why Multipart/mixed java mail content is sent as attachment in outlook? 我无法使用javamail代码通过Outlook(hotmail account)配置发送邮件,但在gmail中工作正常 - I am not able to send mail with outlook(hotmail account) configuration using javamail code but in gmail working fine 使用Hotmail帐户使用Java发送电子邮件 - Send e-mail with Java using hotmail account javax.mail无法发送邮件到hotmail - javax.mail unable to send mail to hotmail 我尝试在MimeMessage的Java方法中发送带有主体内容附件的电子邮件时,主体内容未发送 - Body content is not being sent while I am trying to send an email with attachment with main body content in Java methods of MimeMessage 使用现有 InputStream 作为附件内容使用 javax.mail 发送电子邮件 - Send email with javax.mail using an existing InputStream as attachment content 无法使用Java Mail API发送带有附件的html内容 - Unable to send html content with attachment using java mail api 无法通过邮件发送附件 - Failed to send attachment as mail
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM