MessagingException, IOException
IOException
    public static void processDaily(Context context) throws SQLException,            MessagingException, IOException    {        // Grab the subscriptions        TableRowIterator tri = DatabaseManager.query(context,                "SELECT * FROM subscription ORDER BY eperson_id");        EPerson currentEPerson = null;        List collections = null; // List of Collections        // Go through the list collating subscriptions for each e-person        while (tri.hasNext())        {            TableRow row = tri.next();            // Does this row relate to the same e-person as the last?            if ((currentEPerson == null)                    || (row.getIntColumn("eperson_id") != currentEPerson                            .getID()))            {                // New e-person. Send mail for previous e-person                if (currentEPerson != null)                {                    sendEmail(context, currentEPerson, collections);                }                currentEPerson = EPerson.find(context, row                        .getIntColumn("eperson_id"));                collections = new ArrayList();            }            collections.add(Collection.find(context, row                    .getIntColumn("collection_id")));        }        // Process the last person        if (currentEPerson != null)        {            sendEmail(context, currentEPerson, collections);        }    }