$toAddresses = $email->email2ParseAddresses($emailAdrrs);
     }
     if (isset($officeParams['emailtemplate'])) {
         $templateId = $officeParams['emailtemplate'];
     } else {
         $templateId = '';
     }
     $answer['email'] = $mod_strings['BOX_SEND_ON_EMAIL'] . ': ';
     if (!empty($toAddresses)) {
         if (!isset($noteFileName)) {
             $tmpFileName = $sugar_config['upload_dir'] . uniqid() . uniqid();
             file_put_contents($tmpFileName, $document->getContent());
             $res = Reports_Utils::sendEmailTemplate($filename, $tmpFileName, $toAddresses, $templateId, $seed);
             unlink($tmpFileName);
         } else {
             $res = Reports_Utils::sendEmailTemplate($filename, $noteFileName, $toAddresses, $templateId, $seed);
         }
         if ($res['status'] == FALSE) {
             $answer['email'] .= $mod_strings['OTH_FAIL'] . ' ' . $res['error'];
         } else {
             $answer['email'] .= $mod_strings['OTH_SUCCESS'];
         }
     } else {
         $answer['email'] .= $mod_strings['OTH_FAIL'] . ' ' . $mod_strings['ERR_INVALID_EMAILS'];
     }
 }
 // download report for user
 if (isset($officeParams['download'])) {
     $historyBean->download_on_pc = true;
     if ($officeConfig['officeDocxHistorySave'] === TRUE) {
         $historyBean->save();