在java中创建一个电子邮件对象并将其保存到文件中 [英] Create an email object in java and save it to file

查看:182
本文介绍了在java中创建一个电子邮件对象并将其保存到文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要备份PST文件(outlook存储)中包含的电子邮件。
我正在使用libpst,这是我在网路上找到的唯一免费的图书
http://code.google.com/p/java-libpst/

i need to backup the emails contained in a PST file (outlook storage). i'm using libpst which is the only free library i found on the web ( http://code.google.com/p/java-libpst/ )

所以我可以访问每个单独的所有信息电子邮件
(subject,body,sender ecc ..),但是我需要把它们放在一个文件上。

so i can access all the information in each single email (subject, body, sender ecc..), but i need to put them on a file

这里有人说你可以创建一个EML文件一个javax.mail.Message对象:
创建一个Java中的.eml(email)文件

here someone said you can create an EML file from a "javax.mail.Message" object: Create a .eml (email) file in Java

问题是:如何创建此Message对象?
我没有服务器或电子邮件会话,只是电子邮件中包含的信息

the problem is: how do i create this Message object? i don't have a server or an email session, just the information contained in the email

p.s。
创建一个.msg文件也会很好

p.s. creating a .msg file would be fine too

推荐答案

您创建一个Message对象,就像创建一个Message对象一样发送,
,而不是发送它,你写一个文件。你不需要一个电子邮件
服务器。有很多示例在演示程序中创建消息
包含在 JavaMail下载,以及 JavaMail常见问题解答 。请参阅
留言.writeTo方法将消息写入文件(消息是部分,
和writeTo在部分)。

You create a Message object the same way you would create one for sending, but instead of sending it you write it to a file. You don't need an email server. There's lots of examples of creating messages in the demo programs included with the JavaMail download, and in the JavaMail FAQ. See the Message.writeTo method to write the message to a file (Message is a Part, and writeTo is on Part).

这篇关于在java中创建一个电子邮件对象并将其保存到文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆