Sending mail from UNIX in courier font


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending mail from UNIX in courier font
# 1  
Old 07-26-2013
Code 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
Code:
#!/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

Code:
uuencode file.html file.html|mailx -s "<subject>" sample@mail.xom
cat file.html | mailx -s "<subject>" sample@mail.xom

Code:
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

Code:
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

# 2  
Old 07-26-2013
Use HTML TABLE to format it better. Also no need to create a temporary file, just pipe it to sendmail instead:
Code:
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

This User Gave Thanks to Yoda For This Post:
# 3  
Old 07-26-2013
Or, perhaps, don't use <table> or <tr> and simply wrap the data in <pre> to preserve formatting.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 4  
Old 07-26-2013
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 .
# 5  
Old 07-26-2013
Quote:
Originally Posted by ajayram_arya
Outlook still doent indent properly

Do you know of any changes i need to make to the outlook to get the result.
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:
Code:
print "<TD ALIGN=LEFT><FONT FACE=Courier SIZE=5>" $i "</FONT></TD>"

The ALIGN attribute can have below values:
Code:
left
right
center
justify
char

# 6  
Old 07-26-2013
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 . .

Code:
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

# 7  
Old 07-26-2013
Quote:
Originally Posted by ajayram_arya
Thank you very much Yodi . Outlook still doent indent properly
Outlook is infamous for ignoring formatting and doing whatever it pleases. It's not unheard of to resort to .txt attachments to preserve it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sending e-mail from unix

Hello, I want to send an email from unix. I tried following commands: mailx -s "hello" manish.xxx@xxx.com < echo_manish and echo "Testing Mail" | mailx -s "hello" manish.xxx@xxx.com but in both the commands nothing is happening. I mean it is neither giving any error nor I am receiving... (7 Replies)
Discussion started by: manishdivs
7 Replies

2. Shell Programming and Scripting

Font change in unix while sending email

Hi, I know that we would be require HTML to change the font and color of the text of the output, if we wnt to send that through the email. But I have managed to get below code, can someone look into it and let me know if i can acheive my requirement through this kind of code: Following can... (9 Replies)
Discussion started by: amit.mathur08
9 Replies

3. Shell Programming and Scripting

Sending mail in unix

Dear Friends, I have a shell script where the mail is being sent like this: /usr/lib/sendmail -v ${CPA_ADMIN} CPA_ADMIN="xx@abc.com" Can we specify more than one email ids in this variable? Is ther eany limit to the number of email ids I can specify in this variable, to whom the mail... (3 Replies)
Discussion started by: Radhe
3 Replies

4. UNIX for Dummies Questions & Answers

sending mail from unix

Hi, I am using mailx command to send mail through Unix. But I am able to send mail only within my domain. If i want to send mail to some other server, it's not working. Like say If I want to send mail to someone on gmail or yahoo it's not working. but it's working fine within my company domain.... (3 Replies)
Discussion started by: anki_1
3 Replies

5. Programming

Sending mail in C/C++ in unix server

Hi Frnds, I have a task in my project wherein i have to send out a mail from my C++ code.With some file attachements.Please help me in this. At a higher level wat i can tell is my code generated 3 csv file and i have to send these files as attachement. My code is executed in unix... (6 Replies)
Discussion started by: electroon
6 Replies

6. UNIX for Dummies Questions & Answers

sending mail from unix is failing

i am sending mails from my unix server to my mail id i used sendmail option previously it ran successfully now it is not sending mails what might be the problem this is the message i am getting in /var/mail/abcdev file how to rectify this? ----- The following addresses had permanent... (1 Reply)
Discussion started by: trichyselva
1 Replies

7. UNIX for Dummies Questions & Answers

Sending mail thu unix

Hello everybody. Is it possible in unix to send a mail to my acount like (abcd@xyz.com) if yes then how ?? Thank You !! (6 Replies)
Discussion started by: hellotosatish
6 Replies

8. HP-UX

How to change font and colour in mail sent from Unix

Dear All, We have following code to send mails from unix to users. We want to see few sentences of mail in bold font or to hightlight few lines in different colours. Could you please let me know how can we do it in function construct_body. ... (3 Replies)
Discussion started by: yogichavan
3 Replies

9. Shell Programming and Scripting

Sending Mail Thru Unix Script

What are all the things that should be configured in order to send a mail from Unix box. An eg. program of sending a mail will help me a lot!!!!!! Thanks in advance -Om (5 Replies)
Discussion started by: Omkumar
5 Replies

10. Post Here to Contact Site Administrators and Moderators

font courier doesn't seem to work for me

font courier doesn't seem to work for me -- I get this when I try to use it: font courier doesn't seem to work for me (6 Replies)
Discussion started by: ropers
6 Replies
Login or Register to Ask a Question