creating file, writing file and attaching multiple files to an email, only should attach one per email |
[eluser]Brad K Morse[/eluser]
I have a function that emails each venue chairman an email with an attached excel file, that is generated using the http://codeigniter.com/wiki/Excel_Plugin/ plugin, it was modified to write the file to the directory "./attachments", and return true if it wrote the file. I am testing this and in some emails, I'll have 8 attachments, some will have 3 or 4, but each email should contain only one attachment. I read thru my code and do not know why it attaches multiple files to the email. The files open properly in excel and display the appropriate data, but each email should contain only one attachment. Any help is appreciated. Controller function Code: // email lists to each venue Snippet of the code that I replaced the forced download code with, it writes the file to the directory. save_excel_file_pi.php: Code: if ( ! write_file('./attachments/'.$filename, $data)) { Attached is an image of the attachment portion of one of the emails, it might not be helpful, but I figured I'd include it. Let me know if you need more info. RESOLVED: added Code: $this->email->clear(TRUE);
[eluser]InsiteFX[/eluser]
I think it is because you have this code in the foreach loop Code: if(save_excel_file($query, $filename, $fieldnames)) { // if a file was written in plugin Then use a foreach to email the attachments. In other words I would break it down more to have a method to create the ecel attachments and create another method to send the emails. InsiteFX
[eluser]Brad K Morse[/eluser]
Thanks! Put the email code into a private method. |
Welcome Guest, Not a member yet? Register Sign In |