// Don't read past the end.
if (startIndex + i >= MailItems.getMailItemCount()) {
break;
}
MailItem item = MailItems.getMailItem(startIndex + i);
// Add a new row to the table, then set each of its columns to the
// email's sender and subject values.
table.setText(i + 1, 0, item.sender);
table.setText(i + 1, 1, item.email);