diff --git a/ajax/output/sendMail.php b/ajax/output/sendMail.php index 9beae3135486f8065726563305ed3ab7e4194eb2..1dab545d16cd58a603ab80819b77777742c6ea2d 100644 --- a/ajax/output/sendMail.php +++ b/ajax/output/sendMail.php @@ -48,18 +48,26 @@ function ( !empty($mailAttachmentMediaFileIds) && Permission::hasPermission(ERPOutput::PERMISSION_ATTACH_EMAIL_FILES) ) { - $Media = QUI::getRewrite()->getProject()->getMedia(); - $mailAttachmentMediaFileIds = json_decode($mailAttachmentMediaFileIds, true); + $Project = QUI::getRewrite()->getProject(); - foreach ($mailAttachmentMediaFileIds as $fileId) { - if (empty($fileId)) { - continue; - } + if ($Project) { + $Project = QUI::getProjectManager()->getStandard(); + } + + if ($Project) { + $Media = $Project->getMedia(); + $mailAttachmentMediaFileIds = json_decode($mailAttachmentMediaFileIds, true); + + foreach ($mailAttachmentMediaFileIds as $fileId) { + if (empty($fileId)) { + continue; + } - try { - $attachedMediaFiles[] = $Media->get((int)$fileId); - } catch (Exception $Exception) { - QUI\System\Log::writeException($Exception); + try { + $attachedMediaFiles[] = $Media->get((int)$fileId); + } catch (Exception $Exception) { + QUI\System\Log::writeException($Exception); + } } } }