mardi 18 décembre 2018

Java Setting recipients for email notification

need some enlightenment in this if-else statement for my email notification. I've tried debugging it, and for now it only manage to run the code of adding first recipient (i.e. "TregEmail"). In the case if "TregEmail" is not found, it runs the else if statement to get "TregAplEmail" but directly skips to param.setRecipients(recipients); It doesnt add the "TregAplEmail"

Can anyone suggest me how to go about sending to TregEmail (when it's provided) else get TregAplEmail and send to the latter recipient instead? Many thanks

ArrayList<String> recipients = new ArrayList<>();

if (coTraderReg.getTregEmail() != null) {
    recipients.add(coTraderReg.getTregEmail());
} else if (coTraderReg.getTregAplEmail() != null) {
    recipients.add(coTraderReg.getTregAplEmail());
} else {
    log.error("Account email address not found for " + coTraderReg.getTregId());
}

param.setRecipients(recipients);

Aucun commentaire:

Enregistrer un commentaire