CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Send Insert Emails to All Addresses in a table

Print topic Send  topic

Author Message
hydrazi

Posts: 12
Posted: 02/14/2011, 11:10 AM

Hello,

I want to be able to send an email alert about an insert to a certain table. I want it to send to each email address listed in another table.

I know how to send the insert alert. It works fine for my email address, hard-coded.

How do I create a $email_to that lists all the emails in a table?


_________________
Matt Rand
View profile  Send private message
JayEdgar


Posts: 77
Posted: 02/15/2011, 6:45 AM

Run a query of the table that has the email addresses.
View profile  Send private message
hydrazi

Posts: 12
Posted: 02/15/2011, 7:26 AM

Where do I put the code? I tried this from another post:

function GetAddresses() {
// Create a datasource on the fly, and read the "to" info
$db = new clsDBInternetDB();
$SQL = "SELECT Emailaddress FROM Emails"; // ** Change to match your database **
$db->query($SQL);

$to = "";

$sep = ""; // separator between addresses
if ($db->next_record())
{
do
{
$to = $to . $sep . $db->f("Emailaddress"); // ** Change the field name to match your database **
if (!$sep) {
$sep = ", "; // Subsequent addresses get separated by a comma
}
} while ($db->next_record());
}
return $to;

} // end of function.


It errors telling me that clsDBInternetDB() is not a recognized class. Any ideas?
_________________
Matt Rand
View profile  Send private message
Waspman

Posts: 948
Posted: 02/15/2011, 8:35 AM

this is straight out of my registration page...


global $eb_regnotify;
global $db_regnotify;

$db_regnotify = new clsDBConnection1();
$SQL = "SELECT firstname, lastname, email FROM tb_users WHERE RecievesEmails = 1";
$db_regnotify->query($SQL);
while ($db_regnotify->next_record()) {

$eb_regnotify = "Hi,".$db_regnotify->f("firstname");
$eb_regnotify = $eb_regnotify."The following student has registered<br><br><br>";
$eb_regnotify = $eb_regnotify."Name: ".$Container->firstname->GetValue()." ".$Container->lastname->GetValue()."<br><br><br>";
$eb_regnotify = $eb_regnotify."Go to the administration area for more details<br><br>";


$to = $db_regnotify->f("email");
$subject = "Registration Notification";
$message = $eb_regnotify;
$from = $Sender;
$charset = "Windows-1252";
$transferEncoding = "";
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/html; charset=$charset\nContent-Transfer-Encoding: $transferEncoding";
mail ($to, $subject, $message, $additional_headers);


}

$db_regnotify->close();
_________________
http://www.waspmedia.co.uk
View profile  Send private message
datadoit
Posted: 02/15/2011, 8:56 AM

Reference the connection object first:

global InternetDB;
hydrazi

Posts: 12
Posted: 02/20/2011, 10:33 AM

Awesome! That did it! Many thanks! Now I learned how to do similar things too!!!
_________________
Matt Rand
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.