/**
  * Create a email based on it's theme an params
  *
  * @param string $address
  * @param string $name
  * @throws Exception
  * @return \Zend\Mail\Message
  */
 protected function _constructEmail($address, $name)
 {
     $content = $this->_template->render();
     if ('' == $this->_replyTo) {
         $this->_replyTo = $this->_template->getTestament()->getReplyTo();
     }
     if ('' == $this->_fromName) {
         $this->_fromName = $this->_template->getTestament()->getFromName();
     }
     if ('' == $this->_fromAddress) {
         $this->_fromAddress = $this->_template->getTestament()->getFromAddress();
     }
     if ('' == $this->_subject) {
         $this->_subject = $this->_template->getTestament()->getFromAddress();
     }
     $contentParts = array();
     $partText = new Part($content->getText());
     $partText->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
     $partText->type = Mime::TYPE_TEXT;
     $contentParts[] = $partText;
     $partHtml = new Part($content->getHtml());
     $partHtml->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
     $partHtml->type = Mime::TYPE_HTML;
     $partHtml->charset = 'UTF-8';
     $contentParts[] = $partHtml;
     $alternatives = new \Zend\Mime\Message();
     $alternatives->setParts($contentParts);
     $alternativesPart = new Part($alternatives->generateMessage());
     $alternativesPart->type = "multipart/alternative; boundary=\"" . $alternatives->getMime()->boundary() . "\"";
     $body = new \Zend\Mime\Message();
     $body->addPart($alternativesPart);
     foreach ($this->_attachments as $attachmentSrc) {
         $attachment = new Part(fopen($attachmentSrc['filelocation'], 'r'));
         $attachment->filename = $attachmentSrc['filename'];
         $attachment->encoding = Mime::ENCODING_BASE64;
         $attachment->type = Mime::DISPOSITION_ATTACHMENT;
         $attachment->disposition = true;
         $body->addPart($attachment);
     }
     $subject = $this->_subject;
     foreach ($this->_variables as $name => $variable) {
         $subject = str_replace('{{:' . $name . ':}}', $variable, $subject);
     }
     $message = new Message();
     $message->setSubject($subject);
     $message->setFrom($this->_fromAddress, $this->_fromName);
     if ($this->_replyTo) {
         $message->setReplyTo($this->_replyTo);
     }
     $message->setBody($body);
     $message->setTo($address, $name);
     $message->setEncoding("UTF-8");
     return $message;
 }