I have gone through multiple documents for this question and have applied those steps but so far in vain. I have written a code for excel file but I want to get its contents in the same file and use them as an attachment of excel file using PHPMailer function.
Below is the code I am using after creating excel file:
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
$data = ob_get_contents();
$email->SetFrom('sample@gmail.com', 'Talal Haider'); //Name is optional
$email->Subject = 'Test Mail';
$email->Body = 'Simple Test Email';
$email->AddAddress( 'sample@gmail.com' );
//$email->AddAddress( 'rimsha.cheema@gmail.com' );
$email->AddAttachment($data, 'Inspection_Report.xls' );
if($email->Send()){
echo "Mail Sent";
} else{
echo "Mail Failed";
}
Please guide me in the right direction. Thanks a lot