public static void main (String args[]) 
	throws Exception {
		String host ="omnimail1.omnifax.xerox.com"; 
		String username ="edi"; 
		String password ="ediedi"; 
		// Get session
		Session session = Session.getInstance(
				new Properties(), null);
		// Get the store
		Store store = session.getStore("imap");
		store.connect(host,username,password);
		// Get folder
		Folder folder = store.getFolder("INBOX/AIG/EQ");
		folder.open(Folder.READ_ONLY);
		BufferedReader reader = new BufferedReader (
				new InputStreamReader(System.in));
		// Get directory
		Message message[] = folder.getMessages();
		for (int i = message.length-1,n=message.length;n>i&&i!=-1;i--) {
			Date e = message[i].getSentDate();
			System.out.println("Message Inbox date :"+e);

			Address[] a;
			if ((a=message[i].getFrom())!=null) {
				for (int j=0;j<a.length;j++)
					System.out.println("From : " +a[j].toString());
			}
			Calendar cal = Calendar.getInstance();
			SimpleDateFormat fmt1 = new SimpleDateFormat("yyyy-MM-dd 06:00:00" ); 
			cal.add(Calendar.DATE,-15); //set to 17 days earlier date (15-31)
			fmt1.setCalendar(cal); //set to date after 6am
			String s2 =fmt1.format(cal.getTime()); //returns yesterday's date in string format
			System.out.println("Yesterday's Date in string form before conversion :"+s2 ); 
			SimpleDateFormat fmt2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
			Date d2 = fmt2.parse(s2); //to convert the date in string to date form
			System.out.println("Yesterday's date in date type is: "+d2);
			if (e.after(d2)) { 

				Object content = message[i].getContent();
				if (content instanceof Multipart) {
					System.out.println("Multipart" + i);
					if ((a=message[i].getFrom()) !=null) {
						for (int j=0;j<a.length;j++) {
							System.out.println("From : " +a[j].toString());
							String t = ((a[j].toString()).substring(3,13));
							String m = "AIG - TEST";
							if (t.equals(m)==false)
								handleMultipart((Multipart)content);
						} //end of for (int j=0)
					} //end of if(a=msg[i]) 
				} 
				else {
					System.out.println("ElseMultipart" + i);
					handlePart(message[i]);
				}
			} // end of (if e.after d2) 
			else
				System.out.println("Old message");
		} // end of for loop
		// Close connection 
		folder.close(false);
		store.close();
	} // end of main