Send Email when Printing Report

I received a request to see if it would be possible to send an email when a report is printed. The reasoning is that we want to notify our drivers when a bill of lading is printed so that they are ready to pick up their load. The thought is that once a bol is printed, a load will be ready in ~ 20 minutes and we want to cut back on our drivers calling our logistics team to ask about when something is ready.

Is this something that could be done through advanced printing and routing? Or is there some out of the box functionality that we could possibly use to achieve this?

We don’t have Advanced Printing and Routing, so when I need this I use a Data Directive BPM. It can be done fairly easily, but there is probably an easier way to do it with Advance Printing and Routing. Here’s the data directive I use:

// Data Directive
// Table: SysTask
// Type: Standard

/*____________________________________________

    Widget Block: Condition 0
____________________________________________*/

// Condition - Correct Report

    foreach(var task in ttSysTask) {


        // Task is correct Report
        bool isMyReport = task.TaskDescription.ToLower().Contains( "sales order acknowledgment" ); 

        // Task completed Successfully
        bool taskSuccessful = task.TaskStatus == "COMPLETE";


        // Return true in loop so all may be checked
        if ( taskSuccessful && isMyReport ) 
            return true;

    }

    return false;

// Data Directive
// Table: SysTask
// Type: Standard

/*____________________________________________

    Widget Block: Custom Code 0
____________________________________________*/

using ( var mailer = new Ice.Mail.SmtpMailer(this.Session) ) {


    using ( var message = new Ice.Mail.SmtpMail() ) {


        message.SetFrom("Kevin Veldman <myEmail@company.com>"); 
        message.SetTo("sendTo@company.com");

        message.SetCC( "copy1@company.com; copy2@company.com" );
        //message.SetBcc( "" );

        message.SetSubject( "Order Acknowledgment Printed" );
        message.SetBody( "A Sales Order Acknowledgment has been printed" );
        message.IsBodyHtml = false; 

        mailer.Send( message );
    }
}
    

In the Advance printing routing there is an Icon call Send Email that you can set to send when the report style is printed.

APR is built to email the report being printed. I think I would use code like @kve , but hang it post processing on print bol and maybe only on some status of the shipment, so you don’t have accidental alerts on a misprint.

You can also set the condition to send the email in APR similar to the conditions setting in BPM. If its a simple condition for running the email than APR should enough.

Though, if you want to have more functions or better control over how the email process goes than I do agree that using BPM is better.

1 Like

Thank you all for the suggestions!