如何将 EML 转换为 PST?

How to Convert EMLs to PST?

有人知道如何将我的 EMLs 转换为 PST 的解决方案吗?我搜索了很多,但找不到任何适合 JAVA..

的解决方案

您好,我看到您正在尝试读取 emls,然后将它们放入 PST,

你可以使用 Aspose.Email

但要阅读 EML,您可以使用 java 邮件 API。

例如:

import java.io.*;
import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;

public class EML {

  public static void main(String args[]) throws Exception {

  String host = "192.168.10.205";
  String from = "test@localhost";
  String to = "test@localhost";

  Properties props = System.getProperties();
  props.setProperty("mail.smtp.host", host);
  props.put("mail.transport.protocol", "smtp");

  Session mailSession = Session.getDefaultInstance(props, null);

  File emlFile = new File("message.eml");
  InputStream source = new FileInputStream(emlFile);

  MimeMessage message = new MimeMessage(mailSession, source);

  System.out.println("Subject : " + message.getSubject());
  System.out.println("From : " + message.getFrom()[0]);
  System.out.println("--------------");
  System.out.println("Body : " + message.getContent());
  }
}

用于使用 Aspose.Email

添加 PST
PersonalStorage pst = PersonalStorage.create(dir + "archive.pst", 0);
// create a folder at the root of PST
pst.getRootFolder().addSubFolder("Inbox");
// add message to newly created folder
pst.getRootFolder().getSubFolder("Inbox").addMessage(MapiMessage.fromFile(dir + "my.eml"));

希望对您有所帮助

快乐编码