public function logEmail($result, $subject, $body = NULL, $TOs = NULL, $CCs = NULL, $BCCs = NULL)
    {
        //Log the email attempt
        $recipients = '';
        // add TO addresses
        if ($TOs) {
            foreach ($TOs as $to) {
                if (is_array($to)) {
                    $recipients .= $to['name'] . "<" . $to['email'] . ">;";
                } else {
                    $recipients .= $to . ";";
                }
            }
        }
        // add CC addresses
        if ($CCs) {
            foreach ($CCs as $cc) {
                if (is_array($cc)) {
                    $recipients .= $cc['name'] . "<" . $cc['email'] . ">;";
                } else {
                    $recipients .= $cc . ";";
                }
            }
        }
        // add BCC addresses
        if ($BCCs) {
            foreach ($BCCs as $bcc) {
                if (is_array($bcc)) {
                    $recipients .= $bcc['name'] . "<" . $bcc['email'] . ">;";
                } else {
                    $recipients .= $bcc . ";";
                }
            }
        }
        if ($this->_logType == 'DB') {
            $account = $this->accounts->get($this->useAccount);
            $sender_name = $account->fromName;
            $sender = $account->fromEmail;

            // Store the message log
            $boMessageLog = Openbizx::getObject($this->_logObject);
            $mlArr = $boMessageLog->newRecord();
            $mlArr["sender"] = $sender;
            $mlArr["sender_name"] = $sender_name;
            $mlArr["recipients"] = $recipients;
            $mlArr["subject"] = $subject;
            $mlArr["content"] = $body;
            $mlArr["result"] = $result;
            /*
             * as long as data could read from db, its no longer need to addslashes
              //Escape Data since this may contain quotes or other goodies
              foreach ($mlArr as $key => $value)
              {
              $mlArr[$key] = addslashes($value);
              }
             */
            $ok = $boMessageLog->insertRecord($mlArr);
            if (!$ok) {
                return $boMessageLog->getErrorMessage();
            } else {
                return TRUE;
            }
        } else {
            $back_trace = debug_backtrace();
            if ($result == 'Success') {
                $logNum = LOG_INFO;
            } else {
                $logNum = LOG_ERR;
            }
            Openbizx::$app->getLog()->log($logNum, "EmailService", "Sent email with subject - \"$subject\" and body - $body to - $recipients with result $result.", NULL, $back_trace);
        }
    }