public function onEnviaEmail()
 {
     try {
         TTransaction::open('atividade');
         $object = $this->form->getData('Ticket');
         $vars['tipo_origens'] = $object->tipo_origens;
         $vars['codigo_cadastro_origem'] = $object->codigo_cadastro_origem;
         $vars['solicitante_id'] = $object->solicitante_id;
         $this->onChangeOrigem($vars);
         $this->onChangeTipoOrigem($vars);
         $this->onSetarValoresCombo($vars);
         $status = $object->status_ticket->nome;
         $solicitante = new Pessoa($object->solicitante_id);
         $cliente = $solicitante->pessoa_nome;
         $email1 = $solicitante->email1;
         $empresa = $solicitante->origem_nome;
         $responsavel = new Pessoa($object->responsavel_id);
         $colaborador = $responsavel->pessoa_nome;
         $email2 = $responsavel->email1;
         $table = new TTable();
         $table->border = 0;
         $table1 = new TTable();
         $table1->border = 1;
         $table2 = new TTable();
         $table2->border = 1;
         $table3 = new TTable();
         $table3->border = 1;
         $table4 = new TTable();
         $table4->border = 1;
         $imagem = new TImage('app/images/tecbiz.jpg');
         $imagem->height = 63;
         $imagem->width = 96;
         $row = $table->addRow();
         $cell = $row->addCell($imagem);
         $cell->style = 'width: 100px;';
         $cell = $row->addCell("Prezado <br /> {$cliente} do(a) {$empresa} <br /> Foi registrado um ticket com sua solicitação conforme os dados a seguir:");
         $cell->style = 'width: 700px;';
         $row = $table->addRow();
         $row->addCell('<span style="color: DarkOliveGreen;"><b><u>Inicial:</b></u></span>');
         $row = $table1->addRow();
         $cell = $row->addCell('<b>No. Ticket:</b>');
         $cell->style = 'width: 200px;';
         $cell = $row->addCell($object->id);
         $cell->style = 'width: 600px;';
         $row = $table1->addRow();
         $row->addCell('<b>Título Ticket:</b>');
         $row->addCell($object->titulo);
         $row = $table1->addRow();
         $row->addCell('<b>Data/Hora:</b>');
         $row->addCell(date('d/m/Y H:i'));
         $row = $table1->addRow();
         $row->addCell('<b>Status:</b>');
         $row->addCell($status);
         $row = $table1->addRow();
         $row->addCell('<b>Solicitante:</b>');
         $row->addCell($cliente);
         $row = $table1->addRow();
         $row->addCell('<b>Colaborador TecBiz:</b>');
         $row->addCell($colaborador);
         $row = $table->addRow();
         $cell = $row->addCell($table1);
         $cell->colspan = 2;
         $row = $table->addRow();
         $row->addCell('<span style="color: DarkOliveGreen;"><b><u>Solicitação:</b></u></span>');
         $row = $table2->addRow();
         $cell = $row->addCell('<b>Descrição:</b>');
         $cell->style = 'width: 200px;';
         $cell = $row->addCell($object->solicitacao_descricao);
         $cell->style = 'width: 520px;';
         $cell = $row->addCell($object->data_cadastro);
         $cell->style = 'width: 80px;';
         $row = $table->addRow();
         $cell = $row->addCell($table2);
         $cell->colspan = 2;
         $row = $table->addRow();
         $row->addCell('<span style="color: DarkOliveGreen;"><b><u>Orçamento:</b></u></span>');
         $row = $table3->addRow();
         $cell = $row->addCell('<b>Horas orçadas:</b>');
         $cell->style = 'width: 200px;';
         $cell = $row->addCell($object->orcamento_horas);
         $cell->style = 'width: 600px;';
         $row = $table3->addRow();
         $row->addCell('<b>Valor Hora:</b>');
         $row->addCell('R$ ' . $object->orcamento_valor_hora);
         $row = $table3->addRow();
         $row->addCell('<b>Valor Total:</b>');
         $row->addCell('R$ ' . $object->valor_total);
         $row = $table3->addRow();
         $row->addCell('<b>Forma de pagamento:</b>');
         $row->addCell($object->forma_pagamento);
         $row = $table3->addRow();
         $row = $table->addRow();
         $cell = $row->addCell($table3);
         $cell->colspan = 2;
         $row = $table4->addRow();
         $cell = $row->addCell('<span style="color: red;"><b>Importante:</b></span> Para dar seguimento a esta solicitação será necessário a aprovação da descrição e orçamento deste Ticket');
         $cell->style = 'width: 800px;';
         $row = $table->addRow();
         $cell = $row->addCell($table4);
         $cell->colspan = 2;
         TTransaction::close();
         $ini = parse_ini_file('app/config/email.ini');
         $mail = new TMail();
         $mail->setFrom($ini['from'], $ini['name']);
         $mail->setSubject('TecBiz criou um ticket para voce');
         $mail->setHtmlBody($table);
         $mail->addAddress($email1);
         $mail->addCC($email2);
         $mail->addBCC('*****@*****.**');
         // Se tiver anexo
         if (isset($target_file)) {
             $mail->addAttach($target_file);
         }
         $mail->SetUseSmtp();
         $mail->SetSmtpHost($ini['host'], $ini['port']);
         $mail->SetSmtpUser($ini['user'], $ini['pass']);
         $mail->setReplyTo($ini['repl']);
         $mail->send();
         new TMessage('info', 'Email enviado com sucesso');
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
     $this->form->setData($object);
 }