/**
  * Creates email entity and register it in the email entity batch processor
  *
  * @param EmailHeader           $email
  * @param EmailFolder           $folder
  * @param bool                  $isSeen
  * @param User                  $owner
  * @param OrganizationInterface $organization
  *
  * @return EmailUser
  */
 protected function addEmailUser(EmailHeader $email, EmailFolder $folder, $isSeen = false, User $owner = null, OrganizationInterface $organization = null)
 {
     $emailUser = $this->emailEntityBuilder->emailUser($email->getSubject(), $email->getFrom(), $email->getToRecipients(), $email->getSentAt(), $email->getReceivedAt(), $email->getInternalDate(), $email->getImportance(), $email->getCcRecipients(), $email->getBccRecipients(), $owner, $organization);
     $emailUser->setFolder($folder)->setSeen($isSeen)->getEmail()->setMessageId($email->getMessageId())->setMultiMessageId($email->getMultiMessageId())->setRefs($email->getRefs())->setXMessageId($email->getXMessageId())->setXThreadId($email->getXThreadId());
     return $emailUser;
 }
 /**
  * Creates email entity and register it in the email entity batch processor
  *
  * @param EmailHeader       $email
  * @param EmailFolder $folder
  *
  * @return EmailEntity
  */
 protected function addEmail(EmailHeader $email, EmailFolder $folder)
 {
     $emailEntity = $this->emailEntityBuilder->email($email->getSubject(), $email->getFrom(), $email->getToRecipients(), $email->getSentAt(), $email->getReceivedAt(), $email->getInternalDate(), $email->getImportance(), $email->getCcRecipients(), $email->getBccRecipients());
     $emailEntity->addFolder($folder)->setMessageId($email->getMessageId())->setXMessageId($email->getXMessageId())->setXThreadId($email->getXThreadId());
     return $emailEntity;
 }