get('name'); } protected function setSubject($value) { return $this->set('name', $value); } public function addAttachment(\Espo\Entities\Attachment $attachment) { if (!empty($this->id)) { $attachment->set('parentId', $this->id); $attachment->set('parentType', 'Email'); if ($this->entityManager->saveEntity($attachment)) { return true; } } } public function getBodyForSending() { $body = $this->get('body'); if (!empty($body)) { $attachmentList = $this->getInlineAttachments(); foreach ($attachmentList as $attachment) { $body = str_replace("?entryPoint=attachment&id={$attachment->id}", "cid:{$attachment->id}", $body); } } $body = str_replace("", "
", $body); return $body; } public function getInlineAttachments() { $attachmentList = array(); $body = $this->get('body'); if (!empty($body)) { if (preg_match_all("/\?entryPoint=attachment&id=([^&=\"']+)/", $body, $matches)) { if (!empty($matches[1]) && is_array($matches[1])) { foreach($matches[1] as $id) { $attachment = $this->entityManager->getEntity('Attachment', $id); if ($attachment) { $attachmentList[] = $attachment; } } } } } return $attachmentList; } }