Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Mailx command - send mail as table format

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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. LinuxSomehow the spaces disappeared in the post. Please help. TIA!
Sponsored Links
    #2  
Old Unix and Linux 11-29-2012
only4satish only4satish is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 21 November 2014, 4:47 AM EST
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 Unix and Linux 11-29-2012
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 22 May 2015, 10:54 AM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 07:19 PM.