私は近いと思いますが、メールで$ excelFileを渡す必要がありますが、未定義と言っていますが、$ truckstop_postを渡すとデータは正しくフォーマットされません。まだ。どのようにして\ Excel :: createの結果をMail :: sendに得るのですか?エクセルファイルを電子メールに添付するにはどうすればよいですか?
public function truckstopPost()
{
$type = 'csv';
$truckstop_post = Loadlist::select('pick_city', 'pick_state', 'delivery_city', 'delivery_state', 'trailer_type', 'pick_date', 'load_type', 'length', 'width', 'height', 'weight', 'offer_money', 'special_instructions', 'company_contact', 'contact_phone')->where('urgency', 'OPEN')->orderBy('id', 'desc')->get();
$excelFile = \Excel::create('itransys', function($excel) use ($truckstop_post) {
$excel->sheet('mySheet', function($sheet) use ($truckstop_post)
{
$sheet->fromArray($truckstop_post);
});
$info = Load::find(8500);
$info = ['info'=>$info];
Mail::send(['html'=>'email.invoice_email_body'], $info, function($message) use ($info, $excelFile){
$message->to('[email protected]')->subject('subject');
$message->from('[email protected]', \Auth::user()->name);
$message->attachData($excelFile, 'Invoice.csv');
});
});
return back()->with('status', 'You Posted Truckstop!');
}
これは)私がattachData(へ$ truckstop_postを渡した場合の結果がどのように見えるかであるが、当然のないきれいにフォーマットのCSVファイルのthats
問題であり、正確には何?エクセルを生成しますか?メールに添付しますか? – Dekel
メールに添付する方法、$ message-> attachData(???、 'Invoice.csv');次に何が起こるか - >ダウンロード($タイプ); – mcornille
したがって、質問からファイルの添付ファイルに関連しないものはすべて削除してください。 Xというファイルがあり、そのファイルにアタッチしたいとします。 – Dekel