Java tutorial
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import javax.mail.Message; import javax.mail.MessagingException; public class Main { public static File buildEmlFile(Message message, int i) throws MessagingException, FileNotFoundException, IOException { File file = new File("e:\\" + i + ".eml"); // MimeUtility.decodeText(message.getSubject()).trim() message.writeTo(new FileOutputStream(file)); return file; } }