public static void main(String[] args) throws IOException {
        Reflections reflections = new Reflections(HHq.class.getPackage().getName(), new ResourcesScanner());

        /*
         * Find all resources coming in email-xxx.properties form. When
         * searching, the package part is excluding for matching. But the result
         * resource list comes with names including the package part.
         */
        String[] allPropertiesFiles = reflections.getResources(Pattern.compile("email-.*\\.properties")).toArray(new String[0]);

        Pattern pat = Pattern.compile(".*/email-(.*)\\.properties");

        for (int i = 0; i < allPropertiesFiles.length; i++) {
            Matcher m = pat.matcher(allPropertiesFiles[i]);
            if (m.matches())
                System.out.println("(" + i + ") " + m.group(1));
        }

        /*
         * Let the use choose the email template to use.
         */
        int choice;
        while (true) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            try {
                choice = Integer.parseInt(line);
                if (choice >= 0 && choice < allPropertiesFiles.length) {
                    break;
                }
                System.err.println("Illegal choice.");
            } catch (NumberFormatException e) {
                System.err.println("Please enter a number.");
            }
        }

        Map<String, List<InternetAddress>> unitEmails = new HashMap<>();

        Utils.obtainemail(unitEmails);
        
        final String emailTemplate = allPropertiesFiles[choice];

        Map<InternetAddress, List<String>> emails = unitEmails.entrySet().stream()
                .flatMap(e -> e.getValue().stream().map(email -> Pair.of(email, e.getKey())))
                .collect(groupingBy(Pair::getLeft, mapping(Pair::getRight, toList())));
        
        emails.entrySet().stream().forEach((entry) -> {
            doSendMessage(entry.getKey(), entry.getValue(), emailTemplate);
        });

        // try {
        // doSendMessage(new InternetAddress("jollerlee@mail.ntin.edu.tw"),
        // Arrays.asList("T", "Ϯ]"),
        // emailTemplate);
        // } catch (Exception e1) {
        // e1.printStackTrace();
        // }
        return;
    }