When trying to mail a report instantly

we're getting the following error:
I tracked it to Espo\Modules\Advanced\Tools\Report\SendingService. php
Could you please take a look. Thanks.
we're getting the following error:
Code:
[2026-09-16 06:32:20] DEBUG: API (403) Cannot link an already linked attachment (Email:attachments).; POST /Email; Route pattern: /{controller}; Route params: Array ( [controller] => Email [action] => create )
[2026-09-16 06:32:20] NOTICE: (403) Cannot link an already linked attachment (Email:attachments). :: POST /Email
[object] (Espo\Core\Exceptions\ForbiddenSilent(code: 403): Cannot link an already linked attachment (Email:attachments). at /var/www/html/application/Espo/Core/Exceptions/Forbidden.php:62)
I tracked it to Espo\Modules\Advanced\Tools\Report\SendingService. php
PHP Code:
if ($attachmentId) {
$data->attachmentId = $attachmentId;
$attachment = $this->entityManager->getEntityById(Attachment::ENTITY_TYPE, $attachmentId);
if ($attachment) {
$attachment->set([
'role' => 'Attachment',
'parentType' => Email::ENTITY_TYPE,
'relatedId' => $id,
'relatedType' => ReportEntity::ENTITY_TYPE, // <-- this is the problem
]);
$this->entityManager->saveEntity($attachment);
}
}
