Here you can find the source of saveToEml(Message mail, File emlFile)
public static void saveToEml(Message mail, File emlFile) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import javax.mail.Message; public class Main { public static void saveToEml(Message mail, File emlFile) throws Exception { OutputStream os = null;/* w w w .ja v a 2 s . c o m*/ try { os = new FileOutputStream(emlFile); mail.writeTo(os); } finally { if (os != null) { os.close(); } } } }