문제

I would link to send .odt file generated by TinyButStrong using Swiftmailer. This is mu current code

->setSubject('Customer General Email from '. $date->format("m-d-Y H:i"))
            //->setTo($address)
            ->setFrom('avangardauto33@gmail.com')
            ->attach(
                \Swift_Attachment::newInstance()
                    ->setFilename('space_calculator_results.odt')
                    ->setContentType('application/odt')
                    //->setBody($TBS->Show(OPENTBS_DOWNLOAD, 'space_calc_results.odt'))
                    ->setBody($TBS->Show())
            )
            ->setBody($this->renderView(
                'WinslowUserBundle:User:calc_results_email.html.twig',
                array('data' => $data)), 'text/html');
        $this->get('mailer')->send($message);

I've got the file attached, but I can't open the file with LibreOffice.

So is there any way to get correct file handler to be able to attache it to my email later? Any help is appreciated. Thanks

도움이 되었습니까?

해결책

Method TBS->Show() does not return the binary result of the merge.

According to the manual, you have to do this in order to retrieve the binary content:

$TBS->Show(OPENTBS_STRING);
$string = $TBS->Source; 

So your code could be like this:

$TBS->Show(OPENTBS_STRING);

->setSubject('Customer General Email from '. $date->format("m-d-Y H:i"))
            ->setFrom('avangardauto33@gmail.com')
            ->attach(
                \Swift_Attachment::newInstance()
                    ->setFilename('space_calculator_results.odt')
                    ->setContentType('application/odt')
                    ->setBody($TBS->Source)
            )
            ->setBody($this->renderView(
                'WinslowUserBundle:User:calc_results_email.html.twig',
                array('data' => $data)), 'text/html');
        $this->get('mailer')->send($message);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top