Я пытаюсь отправить электронное письмо, указав в качестве содержимого otp. не понял, в чем проблема, с его содержанием установлено значение null.
public Boolean sendAdminLoginOtp(final CHEMRAdminLoginDetails details)
throws CHEMRException {
if (M_LOG.isDebugEnabled()) {
M_LOG.debug("CHEMRMailerServiceImpl.sendOtpToUserForResetPassword");
}
try {
final String fname = details.getFirstName();
final String lname = details.getLastName();
final Long otp = details.getOtp();
final String email = details.getEmail();
final Session emailSession = getEmailerSession();
final Message message = new MimeMessage(emailSession);
message.setFrom(new InternetAddress(
m_mailerBundle.getString("emrMailerUserName")));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(email));
message.setSubject("noreply-Mail");
/*
* message.setContent("Hi" + details.getFirstName() + " " +
* details.getLastName() +
* ".\n\nYour OTP to Login into your account : " + details.getOtp()
* + "\n\n " + "\n\nThanks\nSupport Team", "text/plain");
*/
message.setContent( "<p>Hi " + fname +" "+ lname + ", "
+ "<br><br>Your OTP to Login into your account : " + otp
+ "<br><br>Thanks,Support Team.</p>", "text/html");
Transport.send(message);
return true;
} catch (final Exception e) {
final String[] replacmentObject = new String[] { e.getMessage() };
M_LOG.error(
"CHEMRMailerServiceImpl Failed to sendOtpToUserForResetPassword.."
+ e.getMessage());
final ErrorRecorder _errorRecorder = m_chemrServicesObjectFactory
.getErrorRecorder();
_errorRecorder.addError(CHEMRErrorCodes.EMRMAILER4001,
replacmentObject);
throw new CHEMRException("ERROR in Manager Layer ::",
_errorRecorder.getErrors());
}
}
Выше приведен код, который я пробовал
![enter image description here](https://i.stack.imgur.com/yVe8I.png)
I have gone through debugging and I came to know content setting null.
введите описание изображения здесь
это исключение, которое я получаю. надеюсь, что кто-нибудь может мне помочь