我尝试通过从文本文件读取数据来发送带有 HTML 表的邮件。该表的格式正确,可以在邮件正文中看到,但我也希望将相同的文本文件作为附件在同一邮件中发送。
这是我正在使用的代码:
awk -F '|' '
BEGIN {
print "From: [email protected]"
print "To: [email protected]"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: Utilization Report"
print "<html><body><font face=verdana size=2 color=black ></br></br> Body of mail. </br> </br></br> <B> Notes of mail.</b></br></br> "
print "<table border=1 cellspacing=1 cellpadding=1 height="75">"
}
!/^#/ && /^S/ {
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
}
!/^#/ && !/^S/ {
print "<tr>"
for ( i = 1; i <= NF; i++ )
print "<td> <center> <font face=verdana size=2> " $i " </center></td>"
print "</tr>"
}
END {
print "</table></body></html>"
}
' /path-of-file/filename.txt | /usr/sbin/sendmail -t uuencode /path-of-file/filename.txt