Email_Sending event

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
droogers
User
Posts: 72

Email_Sending event

Post by droogers »

Hello,

I made a view with an inner join. When I add a record an email is sent. This works good.
The only problem is that not all field are showed in the mail. The field "naam2" in't showed up. This field is from the inner join table.
This is the code from the mail function:

function Email_Sending(&$Email, &$Args) {
//var_dump($Email);
//var_dump($Args);
//exit();
if (CurrentPageID() == "add") { // If Add page
$Email->Format="HTML";
$Email->Charset="ISO-8859-1";
$Email->Recipient = $Args["rsnew"]["naam1"]; // Change recipient to a field value in the new record
$Email->Subject = "Opgave"; // Change subject
$Email->Content = "\nBeste ".$Args["rsnew"]["naam2"].",<br><br>
Bedankt voor je opgave.<br>
Ik kom: ".$Args["rsnew"]["id2"]."<br>
Ik kom naam2: ".$Args["rsnew"]["naam2"]."<br>
Je opgegeven gegevens zijn als volgt:<br>
Graag ontvangen we 1 week voor de activiteit je betaling op bankrekening NL52 INGB 0000 6517 00 t.n.v. conferentiecontact Calvijn.<br><br>
Groeten en tot het aanstaande weekend,<br>
Jose van Duinen</body></html>";
}
return TRUE;
}


mobhar
User
Posts: 11726

Post by mobhar »

Use "ew_ExecuteScalar" global function to get your desired value from a Table or a Database View.

Please read "Some Global Functions" at the bottom of "Server Events and Client Scripts" topic from PHPMaker Help menu for more info and example.


droogers
User
Posts: 72

Post by droogers »

Thanks, but where do I have to place the code:

$value = ew_ExecuteScalar("SELECT naam2 FROM view1");


mobhar
User
Posts: 11726

Post by mobhar »

In the same "Email_Sending" server event.


droogers
User
Posts: 72

Post by droogers »

I tried this code but I got an empty page:

function Email_Sending(&$Email, &$Args) {
//var_dump($Email);
//var_dump($Args);
//exit();
if (CurrentPageID() == "add") { // If Add page
$Email->Format="HTML";
$Email->Charset="ISO-8859-1";
$Email->Recipient = $Args["rsnew"]["naam1"]; // Change recipient to a field value in the new record
$Email->Subject = "Opgave"; // Change subject
$Email->Content = "\nBeste ".$Args["rsnew"]["naam2"].",<br><br>
$value = ew_ExecuteScalar("SELECT naam2 FROM view1")
Bedankt voor je opgave.<br>
Ik kom: ".$Args["rsnew"]["id2"]."<br>
Ik kom naam2: ".$Args["rsnew"]["naam2"]."<br>
Je opgegeven gegevens zijn als volgt:<br>
Graag ontvangen we 1 week voor de activiteit je betaling op bankrekening NL52 INGB 0000 6517 00 t.n.v. conferentiecontact Calvijn.<br><br>
Groeten en tot het aanstaande weekend,<br>
Jose van Duinen</body></html>";
}
return TRUE;
}


mobhar
User
Posts: 11726

Post by mobhar »

Change:
Ik kom naam2: ".$Args["rsnew"]["naam2"]."<br>

to:
Ik kom naam2: ".$value."<br>


droogers
User
Posts: 72

Post by droogers »

I changed the code and now it works. Thanks.

function Email_Sending(&$Email, &$Args) {

	 //var_dump($Email);
	 //var_dump($Args);
	 //exit();

	if (CurrentPageID() == "add") { // If Add page
		$Email->Format="HTML";
		$Email->Charset="ISO-8859-1";
		 $Email->Recipient = $Args["rsnew"]["naam1"]; // Change recipient to a field value in the new record 
		 $Email->Subject = "Opgave"; // Change subject
		$value = ew_ExecuteScalar("SELECT naam2 FROM view1");
		 $Email->Content = "\nBeste ".$Args["rsnew"]["naam1"].",<br><br>
		 
		 Bedankt voor je opgave.<br>
		 Ik kom naam2: ".$value."<br>
		 Je opgegeven gegevens zijn als volgt:<br>
		 Graag ontvangen we 1 week voor de activiteit je betaling op bankrekening NL52 INGB 0000 6517 00 t.n.v. conferentiecontact Calvijn.<br><br>
Groeten en tot het aanstaande weekend,<br>
Jose van Duinen</body></html>";
	}
	 return TRUE;
 }

Post Reply