echo "$1" > test.txt
awk 'BEGIN{
FS="|"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Content-Disposition: inline"
print "<HTML>""<TABLE border="1"><TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>"
}
{
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
}
' test.txt > test.html
cat test.html | mailx -s "TEST" aaa@abc.com
file content:
abc|ccccc|dddd
end html file:
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
<HTML><TABLE border=1><TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>
<TR><TD>AAA</TD><TD>AAAAAA</TD><TD>AAAA</TD></TR>
</TABLE></BODY></HTML>
I am getting email but the its just writing the same end html file into the body instead of creating a table.