📄 receivetask.java
字号:
wb = new HSSFWorkbook(new FileInputStream(AutoMailConstants.BOOTDIR
+ strOutPutFile + "\\"
+ strOutPutFile + ".xls"));
newsheet = wb.getSheetAt(0);
iRowNum = newsheet.getPhysicalNumberOfRows();
//System.out.println("iRowNum:" + iRowNum);
//System.out.println("Message " + j + " from: " + pmm.getFrom());
newrow = newsheet.createRow(iRowNum);
newcell = newrow.createCell((short)3);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(pmm.getSubject());
pmm.setDateFormat("yyyy/MM/dd HH:mm:ss");
newcell = newrow.createCell((short)4);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(pmm.getSentDate());
newcell = newrow.createCell((short)2);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
strTemp = pmm.getFrom();
if(strTemp.indexOf("<") > 0)
{
strTemp = strTemp.substring(strTemp.indexOf("<") + 1, strTemp.indexOf(">"));
}
newcell.setCellValue(strTemp);
getComCustomer(strOutPutFile, strTemp);
//System.out.println("strCom:" + strCom);
//System.out.println("strCustomer:" + strCustomer);
newcell = newrow.createCell((short)1);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(strCustomer);
newcell = newrow.createCell((short)0);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(strCom);
iTemp = 0;
fOut = new FileOutputStream(AutoMailConstants.BOOTDIR
+ strOutPutFile + "\\"
+ strOutPutFile + ".xls");
wb.write(fOut);
fOut.flush();
// Done Deal..
System.out.println("fOut.close");
fOut.close();
//}
message[j].setFlag(Flags.Flag.DELETED, true); //将邮件标记为删除,防止下次重读
}
}
catch(Exception e)
{
s_log.error(pmm.getMailAddress("TO") + e);
System.out.println(e.toString() + " 2");
}
}
else
{
String strFolderName = null;
try
{
String strTemp = pmm.getSubject().trim();
String strSql = "select foldernamem from automail_master where subject =?";
//System.out.println("start0000");
strTemp = strTemp.substring(strTemp.lastIndexOf(":")+1, strTemp.length()).trim();
System.out.println("strTempgetSubject:" + strTemp);
DBHandler handler = new DBHandler();
//System.out.println("start1111111111111");
strFolderName = handler.Handler(conn, strSql, strTemp, 1, 1);
//System.out.println("strFolderName:" + strFolderName);
//System.out.println("start22222222222222");
}
catch(Exception e)
{
System.out.println(e + " get subject from db error");
}
if(strFolderName != null)
{
//System.out.println("start777777777");
try
{
String strAddress = pmm.getFrom();
strAddress = strAddress.substring(strAddress.indexOf("<") + 1, strAddress.indexOf(">"));
System.out.println("strAddress.substring:" + strAddress);
getComCustomer(strFolderName, strAddress);
wb = new HSSFWorkbook(new FileInputStream(AutoMailConstants.BOOTDIR
+ strFolderName + "\\" +strFolderName + ".xls"));
newsheet = wb.getSheetAt(0);
iRowNum = newsheet.getPhysicalNumberOfRows();
newrow = newsheet.createRow(iRowNum);
newcell = newrow.createCell((short)3);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(pmm.getSubject());
pmm.setDateFormat("yyyy/MM/dd HH:mm:ss");
newcell = newrow.createCell((short)4);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(pmm.getSentDate());
newcell = newrow.createCell((short)2);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
strTemp = pmm.getFrom();
if(strTemp.indexOf("<") > 0)
{
strTemp = strTemp.substring(strTemp.indexOf("<") + 1, strTemp.indexOf(">"));
}
newcell.setCellValue(strTemp);
newcell = newrow.createCell((short)1);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(strCustomer);
newcell = newrow.createCell((short)0);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(strCom);
fOut = new FileOutputStream(AutoMailConstants.BOOTDIR
+ strFolderName + "\\" +strFolderName + ".xls");
wb.write(fOut);
fOut.flush();
// Done Deal..
fOut.close();
message[j].setFlag(Flags.Flag.DELETED, true); //将邮件标记为删除,防止下次重读
}
catch(Exception e)
{
System.out.println(e + "unconfirm reply address");
}
}
else
{
try
{
wb = new HSSFWorkbook(new FileInputStream(AutoMailConstants.BOOTDIR
+ "Reply.xls"));
newsheet = wb.getSheetAt(0);
iRowNum = newsheet.getPhysicalNumberOfRows();
newrow = newsheet.createRow(iRowNum);
newcell = newrow.createCell((short)0);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
strTemp = pmm.getFrom();
if(strTemp.indexOf("<") > 0)
{
strTemp = strTemp.substring(strTemp.indexOf("<") + 1, strTemp.indexOf(">"));
}
newcell.setCellValue(strTemp);
pmm.setDateFormat("yyyy/MM/dd HH:mm:ss");
newcell = newrow.createCell((short)1);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
newcell.setCellValue(pmm.getSentDate());
newcell = newrow.createCell((short)2);
newcell.setCellType(HSSFCell.CELL_TYPE_STRING);
newcell.setEncoding((short)1);
//pmm.getMailContent((Part) message[j]);
newcell.setCellValue(pmm.getSubject());
fOut = new FileOutputStream(AutoMailConstants.BOOTDIR
+ "Reply.xls");
wb.write(fOut);
fOut.flush();
// Done Deal..
fOut.close();
message[j].setFlag(Flags.Flag.DELETED, true); //将邮件标记为删除,防止下次重读
}
catch(Exception e)
{
s_log.error("Reply.xls reply address" + e);
System.out.println(e + "Reply.xls reply address");
}
}
}
}
folder.close(true); //将邮件标记为删除,防止下次重读
store.close();
isRunning = false;
//}
}
}
catch(Exception e)
{
try
{
if(conn != null)
{
conn.rollback();
}
}
catch(Exception ee)
{
ee.printStackTrace();
}
e.printStackTrace();
}
finally
{
try
{
if(fOut != null)
{
fOut.close();
}
if(rs != null)
{
rs.close();
}
if(pstmt != null)
{
pstmt.close();
}
if(conn != null)
{
System.out.println("Receiver CONN close");
conn.close();
}
System.out.println("Receiver finally");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -