public void readMails(String folderName) {
		properties = new Properties();
		properties.setProperty("mail.host", "imap.gmail.com");
		properties.setProperty("mail.port", "995");
		properties.setProperty("mail.transport.protocol", "imaps");
		session = Session.getInstance(properties,
				new javax.mail.Authenticator() {
			protected PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(userName, password);
			}
		});
		try {
			store = session.getStore("imaps");
			store.connect();
			inbox = store.getFolder(folderName);
			inbox.open(Folder.READ_ONLY);
			Message messages[] = inbox.search(new FlagTerm(
                    new Flags(Flag.SEEN),false));

			System.out.println("Number of mails = " + messages.length);
			for (int i = 0; i < messages.length; i++) {
				System.out.println("------ok-------");
				Message message = messages[i];
				Address[] from = message.getFrom();
				Enumeration headers = message.getAllHeaders();
				while (headers.hasMoreElements()) {
					Header h = (Header) headers.nextElement();
					maildata.append(h.getName().toString()+":"+h.getValue().toString()+"\n");
				}
				maildata.append("SentDate:"+ message.getSentDate()+"\n");
				maildata.append("Content:"+"\n");      
				getMultiMssage(message);
			    String emaildata=maildata.toString();
				msgid= MailContainExtractor.getMessageID((maildata.toString()));
				new EmailWriter().storeSpamFile(maildata, msgid);
				maildata.delete(0, maildata.length());

			}
			inbox.close(true);
			store.close();
		} catch (NoSuchProviderException e) {
			e.printStackTrace();
		} catch (MessagingException e) {
			e.printStackTrace();
		}
	}