From df528933657f73d546ad6cc431f9537f985f720f Mon Sep 17 00:00:00 2001 From: Luke Miller Date: Sun, 31 Oct 2010 00:20:19 +0100 Subject: Added message loop to ensure simultaneous messages are sent --- workspace/BlaMail/src/com/blatech/blamail/BlaMail.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'workspace/BlaMail/src/com') diff --git a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java index dede9fc..d693355 100644 --- a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java +++ b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java @@ -32,6 +32,7 @@ package com.blatech.blamail; import java.util.Properties; +import javax.mail.Flags; import javax.mail.Folder; import javax.mail.Message; import javax.mail.MessagingException; @@ -98,7 +99,8 @@ public class BlaMail extends Activity { String message; public void run() { - /** monitor e-mail */ + /** check for e-mail */ + try { Properties props = new Properties(); @@ -121,22 +123,23 @@ public class BlaMail extends Activity { store.connect(host, user, pass); - //Get all mails in Inbox Forlder - Folder folder = store.getFolder(mbox); + //Get all mails in Inbox Folder + Folder folder = store.getFolder(mbox); if (folder == null || !folder.exists()) { //System.out.println("Invalid folder"); Toast.makeText(getBaseContext(), "Invalid Folder", Toast.LENGTH_SHORT).show(); System.exit(1); } + folder.open(Folder.READ_ONLY); - + // Add messageCountListener to listen for new messages folder.addMessageCountListener(new MessageCountAdapter() { public void messagesAdded(MessageCountEvent ev) { Message[] msgs = ev.getMessages(); try { - for(int i=0; i