MimeMessage mm = mail.getMessage(); String subject = mm.getSubject(); if (subject != null && subject.startsWith(getCondition())) { return mail.getRecipients(); } return null;