Report Format Data In Email Body

jchellap

Member
QAD Version : QAD Enterprise Applications 2013
OpenEdge Release 11.3.3.023

Dear all,

I am trying to put the report data in the email body.

for e.g.

site item quantity Date
___ _____ _____ ______

site1 item1 10 10/16/16
site2 item2 20 10/17/16.

To achieve this, I am concatenation of the string to form a html tags like string = "<html>" + "<body><tr><td>".

I am getting the email body correctly, However, for few records the alignment is collapsed (for e.g in the email body content i am getting the character "!" which is not available in the table data, then on wards the alignment is gone). I believe the junk characters could cause the issue and replaced it. But still it is not fixed and the junk characters are not visible.

How can we fix the issue?
 

jchellap

Member
OK. This is how I am generating the HTML file.

DEFINE VARIABLE vhtml AS CHARACTER NO-UNDO.

vhtml = "<html><body><table>".

FOR EACH cust:
vhtml = vhtml + "<tr><td>cust.name<td>cust.part<td>cust.service<td>cust.qty<td>cust.invoice-amt</tr>"
End.

vhtml = vhtml + "</table>>/body></html>

output to value("test.html").
put unformatted vhtml.
output close.

Then passing the file test.html as the email body through a customized program.

Results: (Sample report attached)

Xavier Part1 Repair 10 10.567
Peter Part2 Maintenance 9 11.467
!George Part3 Replacement 11 56.7844
Jhon Part4 Re!pair 34 78.677
Billy Part5 Maintenance 9 11.467

FYI. I am aware that few character like "!" are not supported in html. I tried replacing. Actually, these characters are not visible and still creating issues.

Is there any standard QAD program to get the html content as email body?

Please advise. Thanks in advance !!!!
 

Attachments

  • Report.txt
    384 bytes · Views: 5
Last edited:

Fabio

New Member
I don't know how QAD works, but your problem is possibly related to the character encoding in email.

I send all my emails using UTF-8 and I have no issues with it. I use The W3C Markup Validation Service to validate the generated HTML.

You must define your HTML variable as LONGCHAR too, to avoid data that exceeding 32kb limit of CHARACTER variables.

Pay attention to unclosed tags, and on HTML structure.

Test this code to see if it works:

Code:
DEF VAR cHTML AS LONGCHAR NO-UNDO INITIAL ''.
DEF VAR cFile AS CHAR     NO-UNDO INITIAL 'c:\email-report.html'.

cHTML = cHTML + '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"' + '~n'.
cHTML = cHTML + '        "http://www.w3.org/TR/html4/loose.dtd">' + '~n'.
cHTML = cHTML + '<html>' + '~n'.
cHTML = cHTML + '  <head>' + '~n'.
cHTML = cHTML + '    <title>E-mail Report</title>' + '~n'.
cHTML = cHTML + '     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">' + '~n'.
cHTML = cHTML + '  </head>' + '~n'.
cHTML = cHTML + '  <body>' + '~n'.
cHTML = cHTML + '    <div style="padding:0;margin:0;">' + '~n'.
cHTML = cHTML + '      <table cellpadding="0" cellspacing="0" align="center" width="728">' + '~n'.
cHTML = cHTML + '        <tr>' + '~n'.
cHTML = cHTML + '          <th>Name</th>' + '~n'.
cHTML = cHTML + '          <th>Part</th>' + '~n'.
cHTML = cHTML + '          <th>Service</th>' + '~n'.
cHTML = cHTML + '          <th>Qty</th>' + '~n'.
cHTML = cHTML + '          <th>Invoice-Amt</th>' + '~n'.
cHTML = cHTML + '        </tr>' + '~n'.

FOR EACH Cust NO-LOCK:

  cHTML = cHTML + '        <tr>' + '~n'.
  cHTML = cHTML + '          <td align="center">' + Cust.Name        + '</td>' + '~n'.
  cHTML = cHTML + '          <td align="center">' + Cust.Part        + '</td>' + '~n'.
  cHTML = cHTML + '          <td align="center">' + Cust.Service     + '</td>' + '~n'.
  cHTML = cHTML + '          <td align="center">' + Cust.Qty         + '</td>' + '~n'.
  cHTML = cHTML + '          <td align="center">' + Cust.Invoice-Amt + '</td>' + '~n'.
  cHTML = cHTML + '        </tr>' + '~n'.

END.

cHTML = cHTML + '      </table>' + '~n'.
cHTML = cHTML + '    </div>' + '~n'.
cHTML = cHTML + '  </body>' + '~n'.
cHTML = cHTML + '</html>'.

COPY-LOB FROM cHTML TO FILE cFile CONVERT TARGET CODEPAGE 'UTF-8'.

Regards,
 
Top