0

I have a file that I want to email using awk format to HTML to create a table. I would like to include an attachment with it, but can't seem to find a way to do so and I have looked through many examples on the internet and nothing works:

Below is my example:

Inside file:

tshikilt                1
vanrooja                1
dashm                   2
desain02                2
ebrahiiq                2
elizema                 2
naidoowe                2
rajmans                 2
thembapa                2
tshepod                 2
tyesil                  2

Below is my logic to send an email:

 -f /home/chris/ccmenu_alert_email.out ] && cat /home/chris/ccmenu_alert_email.out | awk ' BEGIN {
#print "From: example@'$hostname'.com"
print "To: 'example@gmail.com'"
#print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Subject: L500 user connections on `hostname` has been breached"
print "<html><body><table border=1 cellspacing=0 cellpadding=3>"
print "<tr>"
print "<td>User</td>";
print "<td>Number of Concurrent Sessions</td>";
print "</tr>"
} {
print "<tr>"
print "<td>"$1"</td>";
print "<td>"$2"</td>";
print "</tr>"
} END {
print "</table></body></html>"}' | sendmail -t 

The above works 100% for me, but I need to find a away to include an attachment as part of the same email being sent with the HTML table format. I am stuck at this point - any ideas I can try without having to change much?

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.