Mailx command - send mail as table format | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Mailx command - send mail as table format

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-29-2012
qwertyu qwertyu is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 21 January 2013, 5:12 AM EST
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Mailx command - send mail as table format

I have to send a couple of rows that have been returned from a SQL query. I have written the output of the query to a file and while i try to print this in the mail body the formatting goes wrong.

Intended Output in mail body:
Col1 Col2 Col3
------ ------- ------
Bombay Raj 23
Delhi Raja 24
etc..

But what i get currently is :
Col1 Col2 Col3
---- ----- ------
Bombay Raj 23
Delhi Raja 24
etc..

Please suggest a way how i can format this in the mail body.

P.S: The file to which i re-direct the query output is formatted as required, but the mail body isnt. Please help. TIA!

---------- Post updated at 09:58 PM ---------- Previous update was at 09:56 PM ----------

Sorry the intended output has to have the right amount of spaces. Somehow the spaces disappeared in the post. Please help. TIA!
Sponsored Links
    #2  
Old 11-29-2012
only4satish only4satish is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 21 August 2014, 5:14 AM EDT
Posts: 62
Thanks: 27
Thanked 2 Times in 2 Posts
try using below set in SQL query .....


Code:
 
set pagesize 0
set lines 1000
set echo on 
set heading on



Code:
(cat body; uuencode attch1 attch1; uuencode attch2 attch2; ) | mailx -m -s "testing" ksatisha@ycom

Sponsored Links
    #3  
Old 11-29-2012
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 20 August 2014, 1:27 PM EDT
Location: Galactic Empire
Posts: 3,361
Thanks: 230
Thanked 1,195 Times in 1,124 Posts
Use HTML formatting with sendmail:-

Code:
awk ' BEGIN {
 print "From: abc@pqr.com"
 print "To: xyz@pqr.com"
 print "MIME-Version: 1.0"
 print "Content-Type: text/html"
 print "Subject: Your Subject"
 print "<html><body><table border=1 cellspacing=0 cellpadding=3>"
 print "<tr>"
 print "<td>Col 1</td>";
 print "<td>Col 2</td>";
 print "<td>Col 3</td>";
 print "</tr>"
} {
 print "<tr>"
 print "<td>"$1"</td>";
 print "<td>"$2"</td>";
 print "<td>"$3"</td>";
 print "</tr>"
} END {
 print "</table></body></html>"
} ' SQL_query_output_file | sendmail -t

I hope this helps.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to send html file in a mail not as an attachment but it should display in the mail in table for mani_isha UNIX for Dummies Questions & Answers 0 03-30-2010 03:37 AM
Unable to send e-mail using mailx command manas6 UNIX for Dummies Questions & Answers 1 01-22-2009 03:53 AM
Problem with Mailx command to send mail with attachment viswanatharv Shell Programming and Scripting 5 11-06-2008 01:10 PM
How to convert the data into excel sheet and send mail using 'mailx' command sanbabu Shell Programming and Scripting 5 10-14-2008 04:12 PM
unable to sent mail in html format by mailx command. p_prathaban UNIX for Advanced & Expert Users 17 11-07-2007 02:03 AM



All times are GMT -4. The time now is 10:02 AM.