code: private static Date getSentDate(MimeMessage msg, Date defaultVal) {
          if (msg == null) {
              return defaultVal;
          }
          try {
              Date sentDate = msg.getSentDate();
              if (sentDate == null) {
                  return defaultVal;
              } else {
                  return sentDate;
              }
          } catch (MessagingException me) {
              return new Date();
          }
      }
docs: Compute "sent" date
  
  @param msg        Message to take sent date from. May be null to use default
  @param defaultVal Default if sent date is not present
  @return Sent date or now if no date could be found