Subversion Repositories SmartDukaan

Rev

Rev 5131 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5128 amit.gupta 1
package in.shop2020.catalog.util;
2
 
3
import in.shop2020.utils.GmailUtils;
4
 
5
import java.io.ByteArrayOutputStream;
6
import java.text.DateFormat;
7
import java.text.SimpleDateFormat;
8
import java.util.Date;
9
 
10
 
11
public class ReportSender implements Runnable {
12
	@Override
13
	public void run() {
14
		ReportGenerator repGen = new ReportGenerator();
15
		ByteArrayOutputStream baos = repGen.generateExcelStream(ReportGenerator.TYPE_BOTH);
16
		if(baos != null){
17
			GmailUtils gm = new GmailUtils();
18
			DateFormat dateFormatter = new SimpleDateFormat("yyyy.MM.dd");
19
			String[] recepients = {"amit.gupta@shop2020.in"};
20
			String subject = "Items that require your attention.";
21
			String from = "cnc.center@shop2020.in";
22
			String password = "5h0p2o2o";
23
			String fileName = "items."+ dateFormatter.format(new Date()) + ".xls";
24
			byte [] bytes = baos.toByteArray(); 
25
			try {
26
				gm.sendSSLMessage(recepients, subject, "PFA", from, password, fileName, bytes, "application/xls");
27
			} catch (Exception e) {
28
				e.printStackTrace();
29
			}
30
		}
31
	}
32
}