- Tue Mar 06, 2018 12:03 pm
#813544
Hi,
We have been working on implementing some business processes using ProcessMaker. We have been observing an issue regarding attachments in sending email through ProcessMaker.
Here is the issue in detail.
1. We have a timer task in which it sends some emails to business users with some attachment produced by PM. But we have been observing that emails are sent sometimes without attachment but sometimes email contains attachment.
2. To dig down the problem we have checked each step before sending email but we have found that attachment file exists before sending email.
3. In any process flow, email sending with attachment is working perfectly. But for timer task sometimes emails are sent without attachment and sometimes email is sent without attachment.
4. Following is the code block which is executed on trigger of the timer task.
We have been working on implementing some business processes using ProcessMaker. We have been observing an issue regarding attachments in sending email through ProcessMaker.
Here is the issue in detail.
1. We have a timer task in which it sends some emails to business users with some attachment produced by PM. But we have been observing that emails are sent sometimes without attachment but sometimes email contains attachment.
2. To dig down the problem we have checked each step before sending email but we have found that attachment file exists before sending email.
3. In any process flow, email sending with attachment is working perfectly. But for timer task sometimes emails are sent without attachment and sometimes email is sent without attachment.
4. Following is the code block which is executed on trigger of the timer task.
Code: Select all
Anybody has any idea or any direction for us? We would be very grateful if we could get any suggestion. With this issue we are very much negative concern using PM. Need your help to get rid of this problem.@%emailCounter++;
try{
$to = 'xxxx@gmail.com';
$caseId = @@APPLICATION;
$aAttachments = [];
@@debugStr = "";
@@fileQuery = "select `APP_DOC_UID`, `DOC_VERSION` FROM `APP_DOCUMENT` where `APP_UID`='$caseId' order by `DOC_VERSION` desc limit 1";
$aFiles = executeQuery(@@fileQuery);
@@debugStr .= ";<br/> File counts = ".count($aFiles);
foreach ($aFiles as $aFile)
{
@@debugStr .= ";<br/> File = ".$aFile['APP_DOC_UID'];
$oDoc = new AppDocument();
$aDocInfo = $oDoc->Load($aFile['APP_DOC_UID'], $aFile['DOC_VERSION']);
@@debugStr .= ";<br/> File Info = ".json_encode($aDocInfo);
$ext = '.pdf'; //set to '.doc' if sending a DOC file
$g = new G();
$pathToFile = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP . 'outdocs' . PATH_SEP . $aFile['APP_DOC_UID'] . '_' . $aDocInfo['DOC_VERSION'] . $ext;
@@debugStr .= ";<br/> File path = ".$pathToFile;
$filename = @@selfNamePDF;
$aAttachments = PMFAddAttachmentToArray($aAttachments, $filename, $pathToFile);
}
@@subjectLine = '[Test - attachment] '.@@title;
PMFSendMessage(@@APPLICATION, 'yyyy@zzz.com', $to , 'pppp@gmail.com','' , @@subjectLine, 'TestEmail.html', array(), $aAttachments);
} catch (Exception $e) {
PMFSendMessage(@@APPLICATION, 'yyyy@zzz.com', $to , 'mmmm@gmail.com','' , 'Exception Occured - '.$e->getMessage(), 'TestEmail.html', array(), $aAttachments);
}