Hi emails are working with the CRM, in the email field i can see all my in box, manually import emails in to modules.
within the cases module if i create or update the case it will auto send out a message. but if someone replies to the message, it will not auto add the email to the case.
These are my inbound email settings:
Import Emails Automatically: Yes
Create Case from Email: No
Auto-Reply Template: None
No Auto-Reply to this Domain: none
Leave Messages On Server: Yes
Verify inbound_email_case_subject_macro varialbe in your config.php or config_override.php exit and what is the value of it.
It should be something like,
“Create Case from Email:” - is this create a case from each email received that is not linked to a case? If so, we do not want this.
We want emails with the case reference number in the subject (added by the system) to be automatically added to the case. I think this option is “Import Emails Automatically” ?
Hi regarding the “Create Case from Email” this has made no difference.
The custom/modules/Emails/logic_hooks.php file contains:
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(10, 'Save email case updates', 'modules/AOP_Case_Updates/CaseUpdatesHook.php','CaseUpdatesHook', 'saveEmailUpdate');
Keep the backup of the file modules/AOP_Case_Updates/CaseUpdatesHook.php
replace the function with below code.
4)
Once done make a case update via email and monitor the suitecrm.log
I have made the log statement to fatal so that you will see if it comes in the function, if yes where does it go.
public function saveEmailUpdate($email)
{
$GLOBALS['log']->fatal("comes in saveEmailUpdate");
if ($email->intent !== 'createcase' || $email->parent_type !== 'Cases') {
$GLOBALS['log']->fatal('CaseUpdatesHook: saveEmailUpdate: Not a create case or wrong parent type');
return;
}
if (!isAOPEnabled()) {
$GLOBALS['log']->fatal('AOP is Disabled');
return;
}
if (!$email->parent_id) {
$GLOBALS['log']->fatal('CaseUpdatesHook: saveEmailUpdate No parent id');
return;
}
if ($email->cases) {
$GLOBALS['log']->fatal('CaseUpdatesHook: saveEmailUpdate cases already set');
return;
}
if ($email->fetched_row['parent_id']) {
//Will have been processed already
$GLOBALS['log']->fatal("comes in parent_id. Will have been processed already");
return;
}
$ea = new SugarEmailAddress();
$beans = $ea->getBeansByEmailAddress($email->from_addr);
$contact_id = null;
foreach ($beans as $emailBean) {
if ($emailBean->module_name === 'Contacts' && !empty($emailBean->id)) {
$contact_id = $emailBean->id;
$this->linkAccountAndCase($email->parent_id, $emailBean->account_id);
}
}
$caseUpdate = new AOP_Case_Updates();
$caseUpdate->name = $email->name;
$caseUpdate->contact_id = $contact_id;
$updateText = $this->unquoteEmail($email->description_html ? $email->description_html : $email->description);
$caseUpdate->description = $updateText;
$caseUpdate->internal = false;
$caseUpdate->case_id = $email->parent_id;
$caseUpdate->save();
$GLOBALS['log']->fatal("Case update Done.");
$notes = $email->get_linked_beans('notes', 'Notes');
foreach ($notes as $note) {
//Link notes to case update also
$newNote = BeanFactory::newBean('Notes');
$newNote->name = $note->name;
$newNote->file_mime_type = $note->file_mime_type;
$newNote->filename = $note->filename;
$newNote->parent_type = 'AOP_Case_Updates';
$newNote->parent_id = $caseUpdate->id;
$newNote->save();
$srcFile = "upload://{$note->id}";
$destFile = "upload://{$newNote->id}";
copy($srcFile, $destFile);
}
$this->updateCaseStatus($caseUpdate->case_id);
$GLOBALS['log']->fatal("Ends: saveEmailUpdate");
}