tj71587 Posted October 15, 2007 Share Posted October 15, 2007 Hi there, I have a database filled with email addresses and would like to email them all an excel file, that has different values based on their id number. I generate those excel files with a php script, but I was wondering if there was a way to execute a php script that would automatcially generate the same dyanamic excel file but also email it to the corresponding email? <?php include 'includes/config.php'; include 'includes/opendb.php'; $site1=$_POST['site']; $fromdate=$_POST['months']; $todaydate=date("Y-m-d"); $query ="SELECT ticketno, connect, date, rmnum, problem, resolution, connected FROM helpdesk h WHERE h.sid = '$site1'"; if ($fromdate <> 'All') { $query .= " AND h.date BETWEEN '$fromdate'AND '$todaydate'"; } $query .= " ORDER BY h.ticketno DESC"; $result = mysql_query($query); $tsv = array(); $html = array(); while($row = mysql_fetch_array($result, MYSQL_NUM)) { $tsv[] = implode("\t", $row); $html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>"; } $tsv = implode("\r\n", $tsv); $html = "<table border=1>" . implode("\r\n", $html) . "</table>"; $fileName = 'redwoodtickets.xls'; header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=$fileName"); //echo $tsv; echo $html; include 'includes/closedb.php'; ?> This script is for when an individual is logged in, I would like it to generate over 20 different xls files to email based on each information and email the corresponding xls to the email that is registered. Is this possible or am I just overambitious? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/73329-php-email-with-dynamic-attachments/ Share on other sites More sharing options...
tj71587 Posted October 15, 2007 Author Share Posted October 15, 2007 I am guessing I am being alittle over ambitious then, does anyone even know if this is possible to do? Quote Link to comment https://forums.phpfreaks.com/topic/73329-php-email-with-dynamic-attachments/#findComment-370098 Share on other sites More sharing options...
BlueSkyIS Posted October 15, 2007 Share Posted October 15, 2007 yes, this is possible to do. i have a membership system that attaches dynamic PDFs, Excel is just another variation. look into an existing PHP email class that provides the ability to attach files. and/or learn how to write MIME headers to an email message and then attach a file. Quote Link to comment https://forums.phpfreaks.com/topic/73329-php-email-with-dynamic-attachments/#findComment-370178 Share on other sites More sharing options...
tj71587 Posted October 15, 2007 Author Share Posted October 15, 2007 Thanks for the reply, I havent found any good documentation on how to do this and I am pretty new to php. Would the script I currently use be used when doing this, or would the email and create be in the same script? Quote Link to comment https://forums.phpfreaks.com/topic/73329-php-email-with-dynamic-attachments/#findComment-370256 Share on other sites More sharing options...
tj71587 Posted October 18, 2007 Author Share Posted October 18, 2007 I have been playing around with it for awhile...would the code i currently have work for a project liek this as far as generating or do I basically have to tear down and start back up...Im pretty new to php so I was kinda wondering if anyone can point me in the right direction...I have seen how to email attachements, but havent seen how to send one after generating. Does anyone have experience with this that could share code or if they are not comforatble doing that point me in the right direction. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/73329-php-email-with-dynamic-attachments/#findComment-372001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.