You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

not able to send emails with attachment to mailbox using MailMessage method

Accepted answer
edited Oct 22, 2016 12:27PM in UI Extensibility 3 comments


I am trying to send emails with attachment to mailbox (which used in salesforce CRM) from a custom script using MailMessage method,  its working fine when mail sent to email address but mails are not getting delivered to Mailbox, I want to know is there any difference between sending email to email address and mailbox ? if yes, can anyone suggest me what steps need to follow to achieve this.

Code Snippet

* CPMObjectEventHandler: attachment_ca_mailbox_test
* Package: RN
* Objects: Incident
* Actions: Create, Update
* Version: 1.2
use \RightNow\Connect\v1_2 as RNCPHP;
use \RightNow\CPM\v1 as RNCPM;

class attachment_ca_mailbox_test implements RNCPM\ObjectEventHandler
public static function apply($run_mode, $action, $obj, $n_cycles) 
$inc_ref = $obj->ReferenceNumber;
$mailbox = "[email protected]";
$thread_array = $obj->Threads;
for($i = 0; $i < count($thread_array); ++$i)
$message = $message.$thread_array[$i]->Text."<br>";
$mm = new RNCPHP\MailMessage();
$mm->To->EmailAddresses = array($mailbox);
$mm->Subject = $Subject." ## ".$inc_ref." ## ";
$mm->Body->Text = $message;
$mm->Body->Html = $message;
if(!empty($obj->FileAttachments)) {
    $mm->FileAttachments = new RNCPHP\FileAttachmentArray();
    foreach ($obj->FileAttachments as $key => $file) {
        $mm->FileAttachments[$j] =

Howdy, Stranger!

Log In

To view full details, sign in.


Don't have an account? Click here to get started!