DC
|
Posted: 08/13/2004, 7:41 AM |
|
I'm working on an automated email that will go out to a small group of people in the afterinsert event of a form. The recipient list will change over time and needs to be generated based on a value in the members table.
I am using CC & Php4 w/tmp. I have tried the examples from the gotocode apps but can't find the answers.
//The (seemingly) easy part.... the first line produces no output.
$to = $fldemail;
$subject = "Member Update";
$body = "A member has posted something.";
$headers = "From:me@mysite.com\n";
$headers .= "bcc:me@me.com,you@you.com\n";
mail($to,$subject,$body,$headers);
//The much more difficult part is to alter the second header line to blind copy everyone that has a "Y" in the "members" table, "articles" field. I am clueless as to how I would accomplish the latter.
$headers .= "bcc:him@his.com,her@her.com\n";
Please help! - Thanks, Donna
|
|
|
dataobjx
Posts: 181
|
Posted: 08/15/2004, 5:23 PM |
|
Look at the examples in the CCS help file.
Examples and Techniques --> Programming --> Working with databases --> Retrieve Multiple Field Values from a Database
1.) Create An Email Function
2.) Using the example code from the help file, derive a recordset
3.) Loop through the recordset and call the SendAnEmail function for each record.
Then You will need to perform a loop
While Not EverybodyRS.EOF
sEmailAddress = EverybodyRS.Fields("email")
Call SendAnEmail(sEmailAddr, sEmailBody....)
Wend
Is this what you're after???
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
DC
|
Posted: 08/16/2004, 6:51 AM |
|
I managed to work this out but thank you for responding. I do appreciate it.
For those interested, this is useful for subscriptions and forums.
This code will email multiple subscription or forum members upon insert of a new record. The emails will be blind copies so that everyone's email address is not distributed to the group. There is a separate page that allows members to set their subscription preferences via checkboxes (using the members table).
I added the following code in the AfterInsert event of the form....
$myID = get_session("UserID");
$poster = dlookup("members", "member_login", "member_id=$myID");
$query = "select email from members where membernews='Y'";
$result = mysql_query($query) or die(mysql_error());
while (list ($email) = mysql_fetch_array($result))
{
$to = "$email\n";
$headers = "From:subscriptions@mysite.com\n";
$headers .= "bcc:$email\n";
$subject = "MySIte.com - Email Alert";
$body = "This is an automated message from MySite.com...\n\n $poster has posted Member News titled \"$fldheadline\". \n\n To view this post, \"Sign In\" at www.MySite.com. \n\n\n You are receiving this message because you have subscribed to the MySite Email Alert system.";
mail($to,$subject,$body,$headers);
}
|
|
|
|