Possible to make Breaking/Routing email HTML

Is there anyway to make the body of the email generated by the “Send Email” block in a Breaking/Routing be HTML?

I guess this would apply to the “Send email” blocks in BPM’s as well.

No for routing
Yes for BPMs if you write custom code

Thanks. We purchased Adv Printing Module (APM), just so we didn’t have to write the custom code.

I wasn’t trying to be fancy with the HTML in the email. Just some Bold, and maybe an image for the company Logo.

It would be a real hack, but is there away to intercept the generated email, before it is sent out? I recall there being an email queue table. A Data Directive on that table could check for a key phrase in the body like “” and “” , and then edit the fields that specify the email type.

Nothing inside Epicor… you could intercept it in Exchange… but yuck

You’d be better off just writing a BPM then hacking/intercepting the email. It would take you wayyyy less time. The code for an HTML email is rather simple too. Here is kind of a brief example of HTML email in C#

using System.Net.Mail;

string body = "Insert html code for email body here";

MailMessage mailMessage = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("SMTP SERVER"); 
SmtpServer.Credentials = new System.Net.NetworkCredential("USERNAME", "PASSWORD");
mailMessage.From = new MailAddress(emailFrom);
mailMessage.Subject = subject;
mailMessage.Body = body;
mailMessage.IsBodyHtml = true;
mailMessage.To.Add(new MailAddress(recepientEmail));

//In the event we want to add attachments, this is the location
//		Attachment attachment;
//		attachment = new Attachment(PDFLocation);
 //		mail.Attachments.Add(attachment);
SmtpServer.UseDefaultCredentials = true;
SmtpServer.Port = 587;
SmtpServer.Send(mailMessage);
2 Likes

@mathis1337 yes!, however on a BPM you can use the built in email methods you don’t have to connect / create your own SMTP mailer. You can even do attachments.= with the built in mailer. It has the advantage of being maintained at the Application Level vs hard coded in the code :slight_smile:

var mailer = this.GetMailer(async: true);
var message = new Ice.Mail.SmtpMail();
message.SetFrom("FromEmail@domain.com");
message.SetTo("ToEmail1@domain.com; ToEmail2@domain.com");
message.SetCC("ToCCEmail@domain.com");
//message.SetBcc();
message.SetBody("<html><body><p>Body of Message</p></body></html>");
Dictionary<string, string> attachments = new Dictionary<string, string>();
attachments.Add("Attachment", @"\\Server\Folder\File.pdf");
messge.IsBodyHtml =true;
mailer.Send(message, attachments);
2 Likes

I’ve done them in BPM’s.

But getting all the info into the body require more than just the email wrapper code. I have to query the DB , format the data, create HTML tags for tables, etc…

Maybe I made some wrong assumptions…

Is it possible to have a SSRS report run, rendered as a PDF file, then attach that file to the email created by the BPM?

edit: I see from Jose’s post that attachments are possible. now how to have the SSRS create the PDF file.

Sure thing just call the BO’s to run the report, the file and then attach it as outlined abovoe.

Yeah it is very possible. You’ll have to create something to monitor the output location of the PDF, but I suppose you could do it this way.

Where is the PDF that is generated stored?

Edit: and how will I know which of the files in that location is the one I want to attach?

Jose,

I do know of the built in way, at my company they want everything going through our server. You SMTP doesn’t even really need the credentials, but the higher ups wanted it lol.

Thanks,
Aaron

1 Like

This is what I was talking about. You will have to setup a monitor for the output location of the PDF. Or store the name of the PDF in a temp variable and call once PDF is done being generated, at least you use to have too. There might be an easier way now with SSRS. I personally think by the time you get all this done, the BPM route will have been long done. Formatting an HTML email is rather simple. You can first create a .html file with all the graphics and logos, and then have tags like {bodyTag} and then when sending the email replace the bodyTag with information and you are done. We do this all the time and it is very easy and not too time consuming.

You can use something like StreamReader, and then just use .Replace on the tags and viola. You are done :slight_smile:

1 Like

Yeah all the credentials and such are set in the Company settings but that’s fine

1 Like

I know, but hey, no point is trying to fight the boss man ya know :slight_smile:

1 Like

So the following is possible?

Have a button on the Order Entry screen, than when pressed generates an email with the Order Ack (for this order, using a specific report style) as an attachment.

Something like:

  1. Customize Order Entry screen with:
    a. Add a button on the Summary Sheet.
    b. pressing button updates a field OrderHed.LastDistributed_c with the current date
  2. Create a BPM (or DD?) to monitor the change of OrderHed.LastDistributed_c to:
    a. run the OrdAck report using a preset report style, with its output being a PDF file on the server.
    b. create an email (in Custom code) based on info from the OrderHed record, with the above generated PDF as an attachment.

How exactly do I do step 2.a ?? or is 2.a part of the custom code in 2.b ?

Sure thing, however you should look at Document Sender from Epicor which will do 99% of this already without writing any code.
Otherwise yes it’s all custom code, trace the report print, write the code to invoke it, monitor Task List, get the GUID render the PDF Attach it and email it.

2 Likes

Calvin,
You can insert HTML into your APM email:
Depending on the version you are using the setup steps might be different but… in 2.7 the setup is here:
Output Management > Recipients
(create new or open the one you are using)
The delivery method should be listed as Email, highlight & click edit.
This opens another window, there is a checkbox labeled ‘Include Cover Sheet’ enable that and click configure.
Here you can enter the default subject (with variable placeholders) and the message and there is a checkbox for ‘Send as HTML.’ If you enable that then you would put HTML in the message and it would then be sent that way.

-Rick
www.getaligned.solutions

Rick -

I think I misspoke. I have the “Advanced Printing” not the “Advanced Print Module”.

I’ve never seen any dialog boxs like the ones you posted above (they look very “Windows-esque”, and not very “Epicory”)

Calvin,
we have done what you are wanting to do for one report and it was not the most easy and like Jose said, all custom code. We do something very similiar, we have a button on the sales order entry screen, and once they click this button is send them an email with all the relevant sales order information so there is not need to attach the sales order ack for us. We achieved all this through very simple code too, and it is an HTML email and quite professional looking as opposed to the basic plain text from directives.

Thanks,
Aaron

I’ve already done this (build the email in a BPM) for Shipment notification. That one is 100 % code, and even creates HTML tables based on queries of the tables related to a packer.

It’s just that the powers-that-be want an exact copy of the OrderAck printout to be attached to the email.

They also would really like the the body of the email to look nicer than

Attached is copy of your order

XYZ Corp.
123 Any St
Anytown, USA  18966
1 Like