WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Postie

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Send Text Formatted as a Table

 Keywords: Format Fixed Width Text Column Align Table HTML  

Question:

I am currently using winbatch to send email messages, using the following to format the message:
  
 msg = StrCat("This is sample data ONLY, DO NOT REPLY to this e-mail!",@crlf,@crlf)
 msg = StrCat(msg, company,@crlf,@crlf)
 msg = StrCat(msg,pfrsnm," ",pminit," ",plstnm,"    EMP#  ",pempno,"  PAY PERIOD ENDING- ",pcpedat,"    Check # ",pchknum,@crlf,@crlf)
 msg = StrCat(msg,"-TP-    -RATE-       -HOURS-        -AMOUNT-                   -CURRENT-       -YEAR TO DATE- ",@crlf,@crlf)
 if pca1 > 0.00 then  msg = StrCat(msg,"       ",pcr1,"        ",pch1,"        ",pca1,@crlf)
 if pca2 > 0.00 then  msg = StrCat(msg,"       ",pcr2,"        ",pch2,"        ",pca2,@crlf)
 if pca3 > 0.00 then  msg = StrCat(msg,"       ",pcr3,"        ",pch3,"        ",pca3,@crlf)
 if pca4 > 0.00 then  msg = StrCat(msg,"       ",pcr4,"        ",pch4,"        ",pca4,@crlf)
 if pca5 > 0.00 then  msg = StrCat(msg,"       ",pcr5,"        ",pch5,"        ",pca5,@crlf)
 if pca6 > 0.00 then  msg = StrCat(msg,"       ",pcr6,"        ",pch6,"        ",pca6,@crlf)
 if pca7 > 0.00 then  msg = StrCat(msg,"       ",pcr7,"        ",pch7,"        ",pca7,@crlf)
 msg = strcat(msg,"                                                              GROSS PAY         ",pcgross,"        ",pcygrsa,@crlf)
 msg = strcat(msg,"                                                              F.I.T             ",pcfedwh,"        ",pcyfdwh,@crlf)
 msg = strcat(msg,"                                                              FICA TAX          ",pcficaw,"        ",pcyficw,@crlf)
 msg = strcat(msg,"                                                              S.I.T             ",pcstawh,"        ",pcystwh,@crlf)
 
Sending the emails works great, problem is that the message looks terrible because the columns don't line up. How can I format the msg so that all columnns line up in the email and looks like it should?

Any help you can offer of help will be greatly appreciated.

Answer:

Because most e-mail programs use HTML to display e-mails, you need to use the proper HTML codes to display the font and style you want. I recommend using an HTML table to display formatted columns. Make sure to specify the ‘h’ flag in the kSendText statement.

msg = `<html><body><p>Each table starts with a table tag.<p>Each table row starts with a tr tag.<p>Each table data starts with a td tag.</p>`
msg = StrCat(msg,`<h4>One column:</h4><table border="1"><tr>  <td>100</td></tr></table>`)

msg = StrCat(msg,`<h4>One row and three columns:</h4>`)
msg = StrCat(msg,`<table border="1"><tr>  <td>100</td>  <td>200</td>  <td>300</td></tr></table>`)

msg = StrCat(msg,`<h4>Two rows and three columns:</h4><table border="1"><tr>  <td>100</td>  <td>200</td>  <td>300</td></tr><tr>  <td>400</td>  <td>500</td>  <td>600</td></tr>`)
msg = StrCat(msg,`</table></body></html>`)


AddExtender("WWPST44I.DLL")
host="mail.hollywood.com"
fromaddr="marilyn@hollywood.com"

userid=""
password=""
port=""
tolist="jfk@whitehouse.com"
cclist=""
bcclist=""
subject="Table data sample"
attachments=""
flags="ha"
security=""

kInit(host,fromaddr,userid,password,port,security)
kDest(tolist,cclist,bcclist)
kSendText(subject,msg,attachments,flags)


Article ID:   W17597
Filename:   Send Text Formatted as a Table.txt
File Created: 2012:10:18:12:56:06
Last Updated: 2012:10:18:12:56:06