Sending mail from UNIX in courier font

Need assistance . I have a cvs file which i changed to html file but when i try to send mail to outlook its indent goes wrong. any idea is appreciated .

below are some commands i tried using

Converting csv to html

#!/bin/sh
nawk 'BEGIN{
FS=","
print  "MIME-Version: 1.0"
print  "Content-Type: text/html; charset="us-ascii""
print  "Content-Disposition: inline"
print  "<HTML>"
print  "<BODY>"
}
 {
print  "<P>"
print  "<FONT SIZE="5" FACE="Courier">"
printf "<TR>"
for(i=1;i<=NF;i++)
printf "%s", $i
print "</TR>"
print "</FONT>"
print  "<P>"
 }
END{
print "</BODY></HTML>"
 }
' TempTwo > file1.html
uuencode file.html file.html|mailx -s "<subject>" sample@mail.xom
cat file.html | mailx -s "<subject>" sample@mail.xom
Daily Temp           Temperature      |  Degree Day
Forecast Date  Max Dev Min Dev Avg Dev HDD NDD CDD NDD
Today  Jul 23   85  -6  72   2  79  -2   0   0  14  16
       Jul 24   87  -4  73   3  80  -1   0   0  15  16
       Jul 25   89  -2  71   1  80  -1   0   0  15  16

After mail was sent

Daily Temp           Temperature      |  Degree Day
Forecast Date  Max Dev Min Dev Avg Dev HDD NDD CDD NDD
Today    Jul 23   85  -6   72   2    79  -2    0     0    14   16
            Jul 24   87  -4   73   3    80  -1    0     0    15   16
            Jul 25   89  -2   71   1    80  -1    0     0    15   16

Use HTML TABLE to format it better. Also no need to create a temporary file, just pipe it to sendmail instead:

nawk -F, '
        BEGIN {
                print "To: sample@mail.xom"
                print "Subject: Subject"
                print "MIME-Version: 1.0"
                print "Content-Type: text/html; charset=us-ascii"
                print "Content-Disposition: inline"
                print "<HTML>"
                print "<BODY>"
                print "<TABLE BORDER=0>"
        }
        {
                printf "<TR>"
                for( i = 1; i <= NF; i++ )
                        print "<TD><FONT FACE=Courier SIZE=5>" $i "</FONT></TD>"
                print "</TR>"
        }
        END {
                print "</TABLE>"
                print "</BODY>"
                print "</HTML>"
        }
' TempTwo | /path/sendmail -t
1 Like

Or, perhaps, don't use <table> or <tr> and simply wrap the data in <pre> to preserve formatting.

Regards,
Alister

1 Like

Thank you very much Yodi . Outlook still doent indent properly

Do you know of any changes i need to make to the outlook to get the result.

Appreciate your time.

---------- Post updated at 01:41 PM ---------- Previous update was at 01:32 PM ----------

Alister <pre> doesnt help .

I'm not sure exactly how you want your data to look like!

I would suggest you to try the ALIGN attribute supported by TD tag to specify the required alignment:

print "<TD ALIGN=LEFT><FONT FACE=Courier SIZE=5>" $i "</FONT></TD>"

The ALIGN attribute can have below values:

left
right
center
justify
char	

When you copy the below unix data and paste it in outlook email the format changes . is there any way that what ever the data that is on unix it displays exactly on outlook . .

Forecast Date  Max Dev Min Dev Avg Dev HDD NDD CDD NDD
Today  Jul 23   87  -3  72   2  80   0   0   0  15  15
       Jul 24   86  -4  72   2  79  -1   0   0  14  15
       Jul 25   87  -3  67  -3  77  -3   0   0  12  15
       Jul 26   89  -1  69  -1  79  -1   0   0  14  15

Outlook is infamous for ignoring formatting and doing whatever it pleases. It's not unheard of to resort to .txt attachments to preserve it.

Thank you Corona688 and team for helping me with different ideas . I found the solution .

Alister helped me with html tag <pre> </pre> works like a charm .