简体   繁体   English

java邮件 - 处理csv附件

[英]java mail - processing csv attachment

I am receiving e-mails set from a normal GUI client such as thunderbird or outlook, which conntain message body as String and one csv file attachment. 我正在接收从普通的GUI客户端设置的电子邮件,例如thunderbird或outlook,它将邮件正文作为String和一个csv文件附件。

Using Java mail I would like to process the attachment ie read in the contet of the csv file into a String. 使用Java邮件我想处理附件,即在csv文件的内容中读取一个字符串。 Can I simply check whether the contet is a Multipart and then process the one at index 1 ( I guess e-mail body is at index 0)? 我可以简单地检查一下是否是一个Multipart,然后处理索引为1的那个(我想电子邮件正文是在索引0处)? Or should I check for dispositions which flags which part is an attachment? 或者我应该检查哪些标记哪个部分是附件的处置? My only cocern is that if oe seds an e-mail using a regular GUI client, these flags are not set... 我唯一的问题是,如果oe使用常规GUI客户端发送电子邮件,则不会设置这些标志...

Any comments on what approach to take? 对采取何种方法的任何评论?

此JavaMail FAQ条目将有所帮助。

According to the Javamail tutorial 根据Javamail教程

The content of your message is a Multipart object when it has attachments. 当邮件具有附件时,邮件的内容是Multipart对象。 You then need to process each Part, to get the main content and the attachment(s). 然后,您需要处理每个部分,以获取主要内容和附件。 Parts marked with a disposition of Part.ATTACHMENT from part.getDisposition() are clearly attachments... 在part.getDisposition()中标记为Part.ATTACHMENT的部件显然是附件......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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