/**
   * Set some email's basic information to MailMessage .
   *
   * @param mime
   * @param mailMsg
   * @throws MessagingException
   * @throws ParseException
   */
  private void setMailBasicInfoForMailMsg(MimeMessage mime, MailMessage mailMsg)
      throws MessagingException, ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
    String msgId = mime.getMessageID();
    Address[] from = mime.getFrom();
    Address[] to = mime.getRecipients(RecipientType.TO);
    Address[] cc = mime.getRecipients(RecipientType.CC);
    Address[] bcc = mime.getRecipients(RecipientType.BCC);
    String subject = mime.getSubject();
    Date sendDate = mime.getSentDate();
    String receivedUTCDate = sdf.format(this.resolveReceivedDate(mime));

    mailMsg.setMsgId(msgId);
    mailMsg.setFrom(this.convertToMailAddress(from));
    mailMsg.setTo(this.convertToMailAddress(to));
    mailMsg.setCc(this.convertToMailAddress(cc));
    mailMsg.setBcc(this.convertToMailAddress(bcc));
    mailMsg.setSubject(subject);
    if (sendDate != null) {
      mailMsg.setSendDate(sdf.format(sendDate));
    }
    mailMsg.setReceivedDate(receivedUTCDate);
  }