jonnymorris Posted November 6, 2008 Share Posted November 6, 2008 Hi, I have a regular MySQL query that displays it's results to the screen in a browser as an HTML table, all nice and fruity. The managers who use this function like to send out the results to staff, currently they simply take a screen shot and paste it into an email to send out to everyone - quite an overhead on the email system, company network, not to mention the time taken to do the screen shot and paste it into an email in the first place. It would be good if I could include a standard HTML form button (preferably) or link on the results page to shove the displayed results to Outlook as an email, that contains the table all ready for the manager to add in what ever they want to the email and then send (usually to '[email protected]' but it would be useful if they could change or add to this as they see fit). This is kind of what happens with a normal mailto HTML tag, except I want it to contain the MySQL query result too. This is the existing table output routine (something I inherited): /* Output data into a HTMl table */ echo "<p>"; echo "<table align=center width=800 border=\"1\">"; echo "<tr>"; echo "<td BGCOLOR=\"#ffcc00\"><strong>Agent name</strong></td> <td BGCOLOR=\"#ffcc00\"><strong>Number of calls made / handled</strong></td> <td BGCOLOR=\"#ffcc00\"><strong>Average call minutes</strong></td> <td BGCOLOR=\"#ffcc00\"><strong>Total mins (inc hours + secs rounded)</strong></td> </tr>"; while($row = mysql_fetch_row($numresults)) { echo "<tr>"; for($i=0; $i < mysql_num_fields($numresults); $i++) { echo "<td align=center width=443>$row[$i]</td>"; } echo "</tr>\n"; } echo "</table></p>"; Quote Link to comment https://forums.phpfreaks.com/topic/131610-can-i-make-outlook-pop-up-with-a-generated-email-containing-mysql-query-results/ Share on other sites More sharing options...
predator12341 Posted November 6, 2008 Share Posted November 6, 2008 i believe you can. i no you can fill out a message with some extra perameters on the mailto statement. Just search mail to and you should get how to do it. Quote Link to comment https://forums.phpfreaks.com/topic/131610-can-i-make-outlook-pop-up-with-a-generated-email-containing-mysql-query-results/#findComment-683553 Share on other sites More sharing options...
jonnymorris Posted November 6, 2008 Author Share Posted November 6, 2008 I can find a lot about standard use of mailto: but not a lot about how to write the output of a MySQL query to the message body and have it pop up as a regular email ready for the user to click 'send'. Quote Link to comment https://forums.phpfreaks.com/topic/131610-can-i-make-outlook-pop-up-with-a-generated-email-containing-mysql-query-results/#findComment-683696 Share on other sites More sharing options...
jonnymorris Posted November 7, 2008 Author Share Posted November 7, 2008 I'm not having much luck with this. So far this is what I've come up with, but it doesn't enter anything into the email body: echo "<a href=\"mailto:[email protected]?Subject=Report&Body=" . email_table($numresults) . "\">email</a>"; email_table() is just a function that contains a standard table MySQL output routine (which works perfectly for screen output). This is what I thought would happen, and why I asked the question here. Am I doing something wrong? How can I best achieve this? Please help! Quote Link to comment https://forums.phpfreaks.com/topic/131610-can-i-make-outlook-pop-up-with-a-generated-email-containing-mysql-query-results/#findComment-684442 Share on other sites More sharing options...
harristweed Posted November 7, 2008 Share Posted November 7, 2008 The code below works <?php $hello ="a string"; echo "<a href=\"mailto:[email protected]?Subject=Report&Body=" . $hello . "\">email</a>"; ?> So why not try creating the string variable '$hello' outside of the mail bit? $hello=email_table($numresults); Hope this helps..... Quote Link to comment https://forums.phpfreaks.com/topic/131610-can-i-make-outlook-pop-up-with-a-generated-email-containing-mysql-query-results/#findComment-684464 Share on other sites More sharing options...
jonnymorris Posted November 7, 2008 Author Share Posted November 7, 2008 Thanks, but sorry to say it didn't work when I substituted the string for my function. What's more, $hello does not contain any output from the MySQL query, only the html table header row output by echo commands. Quote Link to comment https://forums.phpfreaks.com/topic/131610-can-i-make-outlook-pop-up-with-a-generated-email-containing-mysql-query-results/#findComment-684503 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.