Html table design is not working in BPM

,

Dear team,
I tried send mail from updatable dashboard and Order details, Po details, etc… html table design structure but, the html table design structure not working.

The below mail code for i tried,

if(toMail !="" && frmEmail!="")
  {
    toMail = "testmail@gmail.com";
    subject="Reg Ready in Days: " + tmpDays;
    Emailbody="Dear "+ custName + ", \n";
    
    Emailbody= Emailbody + "\n\n The following order is ready to dispatch in " + tmpDays + " days."; 
        
    bodyStr = "<html><body><pre style='font: monospace'>";
    bodyStr = bodyStr + "<style>table, th, td {border: 1px solid black;font-family: monospace; font-size: 12px;}";
    bodyStr = bodyStr + "th, td {padding: 5px;text-align: left;}</style>";
    bodyStr = bodyStr + "<table><tbody> <tr><th>Order Number </th> <th> Po Number</th> <th> Part Number</th> <th> Description</th> <th> Qty </th> <th> Actual Delivery Date </th> </tr> <tr><td>"+tmpOrderNo+"</td><td>"+tmpPoNo+"</td><td>"+tmpPartNo+"</td><td>"+tmpDesc+"</td><td>"+tmpQty+"</td><td>"+tmpActDate+"</td> </tr></tbody></table>";
    bodyStr = bodyStr + "</pre></body></html>";
    
    //Emailbody = Emailbody + "<style>table, th, td {border: 1px solid black;border-collapse: collapse; font-family: monospace; font-size: 12px;}";
    
    //Emailbody = Emailbody + "\n\n\n <html><body><pre style='font: monospace'><table style='font-size:15px;font-family:Cambria;' border='1'><tbody> <tr><th>Order Number </th> <th> Po Number</th> <th> Part Number</th> <th> Description</th> <th> Qty </th> <th> Actual Delivery Date </th> </tr> <tr><td>"+tmpOrderNo+"</td><td>"+tmpPoNo+"</td><td>"+tmpPartNo+"</td><td>"+tmpDesc+"</td><td>"+tmpQty+"</td><td>"+tmpActDate+"</td> </tr></tbody> </table></body></html>";
    
    //Emailbody = Emailbody + "<html><body><table style='font-size:15px;font-family:Cambria;' border='1'><tbody> <tr> First </tr> <tr> Second </tr><tr> <td> 1 </td> <td> 2 </td> </tr></tbody></table></body></html>";
    Emailbody = Emailbody + "\n\n" + bodyStr + "\n\n\n\n\n\n\n Regards, \n\n Epicor Email Notification";
    
    var mailer = this.GetMailer(async: false);
    var message = new Ice.Mail.SmtpMail();
    message.SetFrom(frmEmail);
    message.SetTo(toMail);
    //message.SetCC(cc);
    message.IsBodyHtml = true;
    message.SetSubject(subject);
    message.SetBody(Emailbody);
    mailer.Send(message);   
  } 

Kindly, give me solution.

All of the text of the email’s message should be inside the <body>..</body> section

I’d also:

  1. Move the remove the <pre ..> and </pre> tags
  2. Add a <header> section before the body, and put the <style> section in there
  3. Replace the newline char (\n) with a break (<br>)

Your Emailbody variable should end up with the following structure (I’ve inserted values for the the variables you had):

<html>
	<header>
		<style>
		table, th, td {border: 1px solid black;font-family: monospace; font-size: 12px;}
		th, td {padding: 5px;text-align: left;}
		</style>
	</header>
	<body>
	Dear Wile E. Coyote,<br>
	
	<br><br> The following order is ready to dispatch in 7 days.
	<br><br>
	<table>
		<tbody>
			<tr><th>Order Number </th> <th> Po Number</th> <th> Part Number</th> <th> Description</th> <th> Qty </th> <th> Actual Delivery Date </th> </tr>
			<tr><td>1234</td><td>PO54321</td><td>ABC-123</td><td>ACME JET PACK</td><td>1</td><td>11/24/2020</td> </tr>
		</tbody>
	</table>
	<br><br><br><br><br><br><br> Regards, <br><br> Epicor Email Notification
	</body>
</html>

The leading tabs on each line aren’t necessary. I just put them in for readability.

That should give you:

image

Also… you’ll want to clean your variables of any characters that would be interpreted as HTML.

For example, if your description is:

ACME JETPACK 
MAX ALTITUDE > 1500 FT

That > would try become a closing bracket for the HTML. Use substiturion like

bodyStr = bodyStr + "<td>"+tmpDesc.Replace("<","&lt;").Replace(">","&gt;")+"</td>";

Probably others that should be replaced as well, like:
& -> &amp;
" -> &quot;
' -> &apos;

Dear @ckrusen,

Thanks for you quick response. Now, its working. I tried more than hours and new in Epicor product. Thanks again.

Regards,
IsaiSelvan. S

If you do replace the <, >, ', ", and & characters, make sure to replace the & first.

Otherwise, 10' 5" & red would become 10&amp;apos; 5&amp;quot; &amp; red

instead of 10&apos; 5&quot; &amp; red

I usually block these using string variable = $@“formated text”; that way you can easily see what the hell you’re doing

3 Likes

Do the linebreaks in the source code become part of the created string?

For example:

string tst = @"Hello World!
File 'c:\temp.log'";

prints as

Hello World!
File 'c:\temp.log'

or

Hello World!File 'c:\temp.log'

I’ve not used it in that way before, but the @ makes it very very literal. Every space, tab and return should be included in the output.

2 Likes

What indicates the end of the string? The first occurrence of "; (quote followed by a semicolon) ?
Is a line break (in the source code required too?

So if I wanted my string to literally be:
This string has a "; in the middle of it

The following code would work?
string strTemp = @"This string has a "; in the middle of it";

Or would that still need to be escaped?

When I say literal I mean it too

var string1 = $@"This is some log data:
                            Value 1: {value}";

Would produce

This is some log data:
                           Value 1: myvariable-value
var string1 = $@"This is some log data:
Value 1: {value}";

Would produce

This is some log data:
Value 1: myvariable-value

So if you are trying to write to log everything from your string you would not want to be indented.

Once you use the @ there is no more escaping don’t try to put "; in your string. It’s a have your cake and eat it too situation

1 Like