Jump to content

Can I make Outlook pop up with a generated email containing MySQL query results?


Recommended Posts

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>";

 

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.

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'.

 

 

 

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!  ;D

 

 

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.....

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.