Java Reference
In-Depth Information
db.saveEmail(dateString,from,email,subject,contentType,msg);
}
}
}else{
String contentType=messagePart.getContentType();
if (contentType.startsWith("text/plain") ||
contentType.startsWith("text/html")){
String msg = readMsg(messagePart);
db.saveEmail(dateString,from,email,subject,contentType,msg);
}
}
}
catch (Exception ex){
ex.printStackTrace();
}
return true;
}
private static String readMsg(Part messagePart){
String message = "";
try{
String contentType=messagePart.getContentType();
if (contentType.startsWith("text/plain")||
contentType.startsWith("text/html")){
InputStream is = messagePart.getInputStream();
BufferedReader reader = new BufferedReader(new
InputStreamReader(is));
String line = reader.readLine();
while(line!=null){
message = message + line;
line = reader.readLine();
}
}
}catch(Exception e){
System.err.println(e);
}
return message;
}
}
class MailSaver{
private static String dbUserName = "dbUser";
private static String dbPassword = "dbPwd";
Connection con = null;
Search WWH ::




Custom Search