Not able to generate table in email body

Below is the code snippet and I'm not able to generate the table in email, output email has nothing

if [ -f $fName ]; then
echo "File $fName exists."
awk -F "," ' BEGIN {
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: Out OF Network Fee - Portfolio Level Stats"
print "<html><body><table border=1 cellspacing=0 cellpadding=3>"
print "<tr>"
for(i=1;i<=NF;i++)
print "<td>" $i"</td>"
print  "</tr>"
} END {
print "</table></body></html>"
 } ' $fName | mailx email

Welcome to the forum.

Please become accustomed to provide decent context info of your problem.

It is always helpful to carefully and detailedly phrase a request, and to support it with system info like OS and shell, related environment (variables, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two including your own attempts at a solution, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.

Some comments to your above snippet:

  • the fi is missing
  • variable $fname is undefined
  • there's only BEGIN and END sections in the awk snippet; no input is processed. Inserting a }{ before the print "<tr>" might bring you closer.
  • email in not something mailx could send to.