Sending HTML Emails From Within an Epicor 10 BPM

For Epicor ERP: Kinetic, v10, & v9

Sending plain text emails out of an Epicor BPM is pretty simple, you drag the ‘Send Email’ object into your workflow, and you are good to go:

Screenshot of using Epicor BPM workflow designer to send email in HTML format - GingerHelp

This is an incredibly useful tool for sending notifications to users when specific events happen within Epicor that require their attention. We have used them recently to notify a buying manager when they are needed to approve a purchase order over a certain dollar amount. The biggest shortcoming with this tool are:

  1. Making the emails look pretty - you would likely not want to send the sort of notifications it can generate out to customers or other outside entities.

  2. Those times when your logic is complicated, and you don’t want to create dozens of condition objects/variables in your workflow.

Fortunately, Epicor provides us with direct access to the underlying business object that we can easily access within our custom code objects within our BPMs to handily solve both of these shortcomings. Simply enough, use this snippet within your BPM custom code to generate an email:

var mailer = this.GetMailer(async:true);
var message = new Ice.Mail.SmtpMail();

message.SetFrom("DoNotReply@acmecorp.com");
message.SetTo("aellis@gingerhelp.com");
message.SetCC("kcrane@gingerhelp.com");
message.SetSubject("Email Triggered From Shipment");
message.SetBody("Email <b>Body</b> Text");

message.IsBodyHtml = true;
mailer.Send(message);

The fields mimic what is available within the ‘Send Email’ object with the addition of that IsBodyHtml option, which, as you probably guessed, interprets the string in SetBody as HTML. This is the same technique I used for our Beautiful HTML Customer Shipment Notifications product - only with a ton of additional logic to build out that SetBody string.

That’s it - use this technique for all of the ways you can imagine using Amazon-like notifications: order acknowledgments, invoices, RMAs, etc. If you want to get fancy, you can even embed links into that HTML to do everything from tracking shipments to kicking off logic within Epicor via their REST API. Happy coding!