$result = $mailfile->sendfile();
 if ($result) {
     $error = 0;
     // FIXME This must be moved into a trigger for action $trigger_name
     if (!empty($conf->dolimail->enabled)) {
         $mid = GETPOST('mid', 'int') ? GETPOST('mid', 'int') : 0;
         // Original mail id is set ?
         if ($mid) {
             // set imap flag answered if it is an answered mail
             $dolimail = new DoliMail($db);
             $dolimail->id = $mid;
             $res = $dolimail->set_prop($user, 'answered', 1);
         }
         if ($imap == 1) {
             // write mail to IMAP Server
             $movemail = $mailboxconfig->putMail($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $folder, $deliveryreceipt, $mailfile);
             if ($movemail) {
                 setEventMessages($langs->trans("MailMovedToImapFolder", $folder), null, 'mesgs');
             } else {
                 setEventMessages($langs->trans("MailMovedToImapFolder_Warning", $folder), null, 'warnings');
             }
         }
     }
     // Initialisation of datas
     $object->socid = $sendtosocid;
     // To link to a company
     $object->sendtoid = $sendtoid;
     // To link to a contact/address
     $object->actiontypecode = $actiontypecode;
     $object->actionmsg = $actionmsg;
     // Long text