If an attachment is added in case update, the attachment is not sent to the contact

Please help as I am at my wits end. If I can get this resolved, I can roll out SuiteCRM.

I reply to a case and add a document, internal CRM document or external document.

The document shows in the thread but the contact only receives my reply without any attachment.

I am at my wits end here.

SuitCRM 7.10.11
Ubuntu 18.04.1 LTS
PHP 7.2.11-2

When I reply to a case and I add an attachment, Internal document or external file, It shows in the case update thread, but the attachment is not sent to the contact. The contact on receives a reply without attachment.

Here is my error log after the transaction:

Fri Jan 4 14:51:26 2019 [16208][1][ERROR] Unable to find relationship emails_email_templates
Fri Jan 4 14:51:26 2019 [16208][1][ERROR] Unable to find relationship emails_email_templates
Fri Jan 4 14:51:26 2019 [16208][1][ERROR] Unable to find relationship emails_email_templates
Fri Jan 4 14:51:26 2019 [16208][1][ERROR] fromUser: Conversion of 2019-01-04 09:15:01 from user format d/m/Y H:i failed
Fri Jan 4 14:51:26 2019 [16208][1][ERROR] fromUser: Conversion of 2019-01-04 12:51:26 from user format d/m/Y H:i failed
Fri Jan 4 14:51:26 2019 [16208][1][ERROR] fromUser: Conversion of 2019-01-04 09:15:01 from user format d/m/Y H:i failed
Fri Jan 4 14:51:26 2019 [16208][1][ERROR] fromUser: Conversion of 2019-01-04 12:51:26 from user format d/m/Y H:i failed

check this https://github.com/salesagility/SuiteCRM/issues/2174

1 Like

Hi mikebeck

I have tried but cannot get it to work. I am unsure of the following as where exactly to paste:

$sql = "SELECT * FROM notes WHERE parent_id = '".$this->id."'";

`$result = $GLOBALS['db']->query($sql);

while($row = $GLOBALS['db']->fetchByAssoc($result) )
{
    $file_name = $row['filename'];
    $location = "upload/{$row['id']}";
    $mime_type = $row['file_mime_type'];
    $mailer->AddAttachment($location, $file_name, 'base64', $mime_type);
    $mailer->AddEmbeddedImage($location, 'myimagecid', $file_name, 'base64', 'png', 'inline');
}`

Add to AOP_Case_Updates.php to saveEmail() method before
$mailer->Send()

It looks like this:

$mailer->FromName = $emailSettings['from_name'];
        foreach ($emails as $email) {
            $mailer->addAddress($email);
        }
        try {
            if ($mailer->send()) {
                require_once 'modules/Emails/Email.php';
                $emailObj = new Email();
                $emailObj->to_addrs_names = implode(',', $emails);
                $emailObj->type = 'out';

i’m checking now and with the current version of SuiteCRM this no longer works, the structure has changed and this needs to be reviewed

@pgr, please can you move the priority of this error in SuiteCRM, personally and professionally we use a lot the Case system of SuiteCRM and this is not fixed for a long time.

best regards

Hi, I have the same issue.Were you able to fix this?

Actually in function which used for send email has nothing to add attachment. So if we add it, then it should work proper. Here is simple script which can be add in sendEmail function in modules/AOP_Case_Updates/AOP_Case_Updates.php

if($caseId){
        if($_FILES['case_update_file']['size'][0] > 0){
            $atch = $_FILES['case_update_file']['tmp_name'];
            $mailer->AddAttachment($atch[0], $_FILES['case_update_file']['name'][0]);
        }
    }

For more information you can refer this article.

1 Like

Always remember it’s better to add into custom where possible. @efb-technology you reckon this could be added to the core? If so feel free to create a PR on GitHub and I’ll take a look!

1 Like