send email after function Row_CustomAction

im case.
ListOption_rendered:
$this->ListOptions->Items[“new”]->Body = "<a href="#" onclick="return ew.submitAction(event, {action: ‘send’, method: ‘ajax’, msg: ‘Yakin Akan Mengirim?’, key: " . $this->KeyToJson(TRUE) . “});">Send”;
Row_CustomAction:

function Row_CustomAction($action, $row) {
$username = CurrentUserName();
$datetime = CurrentDateTime();
if ($action == “send”) { // Check action name
$rsnew = [“status” => “approve”,“aktorsend” => “$username”,“senddate” => “$datetime”]; // Array of field(s) to be updated
$result = $this->update($rsnew, “id = $row[id]”); // Update the current record only (the second argument is WHERE clause for UPDATE statement)
if (!$result) { // Failure
$this->setFailureMessage("Failed to Send, ID = " . $row[“id”]);
return FALSE; // Abort and rollback
} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
$this->setSuccessMessage(“Berhasil Send Ke Division Head.”);
}
return TRUE; // Success
} }
this work.
but I want after row_customaction I want to send an email?
Can it?
What server events should I use and is there an example of solving a case like this?
thank you

You may just call SendEmail() (see the source in phpfn.php) in your Row_CustomAction event.

function Row_CustomAction($action, $row) {
$username = CurrentUserName();
$datetime = CurrentDateTime();
if ($action == “send”) { // Check action name
$rsnew = [“status” => “approve”,“aktorsend” => “$username”,“senddate” => “$datetime”]; // Array of field(s) to be updated
$result = $this->update($rsnew, “id = $row[id]”); // Update the current record only (the second argument is WHERE clause for UPDATE statement)
$result = SendEmail($this->Sender, $this->Recipient, $this->Cc, $this->Bcc,
$this->Subject, $this->Content, $this->Format, $this->Charset, $this->SmtpSecure,
$this->Attachments, $this->EmbeddedImages, $this->Prop);
if (!$result) { // Failure
$this->setFailureMessage("Failed to Send, ID = " . $row[“id”]);
return FALSE; // Abort and rollback
} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
$this->setSuccessMessage(“Berhasil Send Ke Division Head.”);
}
return TRUE; // Success


is this the syntax?
thx

newbiephp wrote:

$result = SendEmail($this->Sender, $this->Recipient, $this->Cc, $this->Bcc, $this->Subject, $this->Content, $this->Format, $this->Charset, $this->SmtpSecure, $this->Attachments, $this->EmbeddedImages, $this->Prop);

There is no such $this->XXX properties in Row_CustomAction(), you need to provide your actual values for sender, recipient, etc.

function Row_CustomAction($action, $row) {
$username = CurrentUserName();
$datetime = CurrentDateTime();
$fromEmail =‘…@gmail.com’;
$toEmail=‘…@gmail.com’;
$ccEmail =‘…1@gmail.com’;
$bccEmail=‘…@gmail.com’;
$subject =‘…@gmail.com’;
$mailContent=‘okedeh’;
$format =‘tes’;
$charset='tes;
if(CurrentUserLevel()==3){
if ($action == “send”) { // Check action name
$rsnew = [“status” => “send”,“aktorsend” => “$username”,“senddate” => “$datetime”]; // Array of field(s) to be updated
$result = $this->update($rsnew, “id = $row[id]”); // Update the current record only (the second argument is WHERE clause for UPDATE statement)
$result = SendEmail($fromEmail, $toEmail, $ccEmail, $bccEmail, $subject, $mailContent, $format, $charset, $smtpSecure = “465”, $arAttachments = , $arImages = , $arProperties = NULL);
if (!$result) { // Failure
$this->setFailureMessage("Failed to Send, ID = " . $row[“id”]);
return FALSE; // Abort and rollback
} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
$this->setSuccessMessage(“Berhasil Send Ke Division Head.”);
}
return TRUE; // Success
}


I tested it with the script. error does not appear but the email was not sent.
Where do you think it doesn’t work? I think in this variable …
$ format = ‘test’;
$ charset = 'test;
can anyone help? thanks

$divisi = ExecuteScalar(“SELECT divisi FROM user WHERE Username='”.CurrentUserName().“'”);
$namapt = ExecuteScalar(“SELECT nama_pt FROM user WHERE Username='”.CurrentUserName().“'”);
$toemail= ExecuteScalar(“SELECT email FROM user WHERE divisi=‘$divisi’ and nama_pt=‘$namapt’”);
var_dump($divisi);
I tried it and the dump didn’t get a value

Can you do a row_customactions query? I want to get the e-mail then send it to the e-mail with the sendemail function. thanks

query works.
thanks