Skip to content
Snippets Groups Projects
Commit 3b74f94c authored by jaapjansma's avatar jaapjansma
Browse files

Added attachment parameter to send e-mail.

parent 394f4ae4
No related branches found
Tags 1.49
No related merge requests found
Version 1.49 (not yet released)
Version 1.49
------------
* Added attachment parameter to send e-mail.
Version 1.48
------------
......
......@@ -7,6 +7,7 @@
namespace Civi\ActionProvider\Action\Communication;
use Civi\ActionProvider\Action\AbstractAction;
use Civi\ActionProvider\Parameter\FileSpecification;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use Civi\ActionProvider\Parameter\SpecificationBag;
use Civi\ActionProvider\Parameter\Specification;
......@@ -52,6 +53,19 @@ class SendEmail extends AbstractAction {
$body_html = $parameters->getParameter('body_html');
$cc = $this->configuration->getParameter('cc');
$bcc = $this->configuration->getParameter('bcc');
if ($parameters->doesParameterExists('attachments')) {
foreach($parameters->getParameter('attachments') as $fileId) {
try {
$file = civicrm_api3('File', 'getsingle', ['id' => $fileId]);
$filename = \CRM_Utils_File::cleanFileName($file['uri']);
$config = \CRM_Core_Config::singleton();
$path = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $file['uri'];
$mailer->addAttachment($path, $filename, $file['mime_type']);
} catch (\CiviCRM_API3_Exception $ex) {
// Do nothing.
}
}
}
$mailer->send($contact_id, $subject, $body_text, $body_html, $extra_data, $cc, $bcc);
}
......@@ -89,6 +103,7 @@ class SendEmail extends AbstractAction {
new Specification('contribution_id', 'Integer', E::ts('Contribution ID'), false),
new Specification('case_id', 'Integer', E::ts('Case ID'), false),
new Specification('participant_id', 'Integer', E::ts('Participant ID'), false),
new Specification('attachments', 'Integer', E::ts('Attachment(s)'), false, null, null, null, true)
));
}
......
......@@ -13,8 +13,8 @@
<url desc="Documentation">https://lab.civicrm.org/extensions/action-provider/wikis/home</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-01-28</releaseDate>
<version>1.49-dev</version>
<releaseDate>2021-02-09</releaseDate>
<version>1.49</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment