/**
  * Constructs an email object for the given order (if possible)
  * @param Order $order
  * @return Email|null
  */
 public function getEmailForOrder(Order $order)
 {
     $data = CustomerDataExtractor::inst()->extract($order);
     $emailAddress = $data['Email'];
     // Send to admin?
     if ($this->To === self::TO_ADMIN) {
         $emailAddress = FollowUpEmail::config()->admin_email;
         if (empty($emailAddress)) {
             $emailAddress = Email::config()->admin_email;
         }
     }
     // Send the email if possible
     if (!empty($emailAddress)) {
         // fill in some additional templating
         $data = $this->performSubstitutions($data, $order);
         // build the email
         $email = new Email();
         $email->setFrom(Email::config()->admin_email);
         $email->setTo($emailAddress);
         $email->setSubject($this->Subject);
         $body = $this->customise($data)->renderWith(array('FollowUpEmail'));
         foreach ($data as $k => $v) {
             $body = str_replace(array('http://{{{' . $k . '}}}', '{{{' . $k . '}}}'), array($v, $v), $body);
         }
         $email->setBody($body);
         return $email;
     } else {
         return null;
     }
 }