This topic is locked
[SOLVED]

 A bit of help on emailing people from the database

12/2/2010 5:29:29 PM
PHPRunner General questions
K
karmacomposer author

I need to email certain fields of searched records, being able to select them, and then somehow choose the email address to send to using a table for the dropdown values.
*note my questions in the remark sections
Here is my code:
// ====================================

// Email Employer suggested Candidates

// ====================================
global $dal;

for ($i=0; $i<count($keys); $i++)

{

if ($keys[$i]["CandidateCCID"])

{
//need to figure out how to get an employer email.

//could we create a popup that allows you to select an email address from the Employer table?
$email="employer@company.com";

$from="admin@clientdatabase.com";
//The suggested candidates need to be inserted into the $msg variable

//How do we do this?
$msg="Candidate data here";

$subject="Suggested Candidates";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}

}

$result["txt"] = "Your email has been sent.";

J
Jane 12/3/2010

Hi,
This code is used to send emails to hard-coded email address.

In general you need to open new window with form where user can select email address and send email in the"Before process" event of this page.
Here is just a sample button:

<INPUT class=button onclick="var form = $('#frmAdmin1')[0];form.a.value='email'; openwin(form); return false;" value="Email selected" type=button>


openwin

is a custom function to open new window.

You can define it in the JavaScript onload event. Here is just a sample:

//define preWin function

var prevWin = null;
function openwin(oForm)

{

if (prevWin && !prevWin.closed)

prevWin.close();

prevWin = window.open('', 'prevWin',

'left=200,top=200,width=750,height=620,status=0');

oForm.target = 'prevWin';

oForm.action = 'TableName_add.asp';

oForm.submit();

if (prevWin && !prevWin.closed)

prevWin.focus();

return true;

}



where TableName is name of th the table where emails will be sent.

Then check GetRequestValue(RequestForm(),"a") variable in the Add page: Before processevent and send selected records to the entered email address (email address should be selected on the TableName_add page).

K
karmacomposer author 12/6/2010

OK. In the following script, how do you tell PHPRunner the path to the _add file? I keep getting errors. I think it is assuming that the database is located on the root of the server (ie: /database) when in reality it is located at a different path (ie: /public_html/server/database/)
What line do I alter and how?
----------------------------------

echo "<script>

var prevWin = null;

function openwin(oForm)

{

if (prevWin && !prevWin.closed)

prevWin.close();

prevWin = window.open('', 'prevWin', 'left=200,top=200,width=750,height=620,status=0');

oForm.target = 'prevWin';

//for CandidateSWT replace email_table_add.php with email_tableswt_add.php

oForm.action = 'Employer_Email_tableCC_add.php';

oForm.submit();

if (prevWin && !prevWin.closed)

prevWin.focus();

return true;

}

</script>

";

echo "<INPUT class=button onclick=\"var form = $('#frmAdmin1')[0]; form.a.value='email'; return openwin(form); return false;\" value=\"Email selected Candidates to Employer\" type=button> ";

Sergey Kornilov admin 12/7/2010

You need to post exact error message here. Impossible to tell what is wrong without seeing the error message.

K
karmacomposer author 12/7/2010



You need to post exact error message here. Impossible to tell what is wrong without seeing the error message.


Error I encountered:
-----------------------------

Not Found
The requested URL /ACESDB/Employer_Email_tableCC_add.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request

-----------------------------
Mike

Sergey Kornilov admin 12/7/2010

You need to make sure file name is spelled correctly (case-sensitive) and this file is actually there.