Add color to part of the text in a mail sent from unix script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Add color to part of the text in a mail sent from unix script
# 1  
Old 05-06-2010
Add color to part of the text in a mail sent from unix script

Hi,

We are using KSH.

I was able to write a script where a mail is sent to the concerned persons and this is working perfectly file. I need to give a different color to a part of the data in the mail which. The script written is as follows;

Code:
(echo "From: $REPLY"
echo "To: $DLIST"
echo "Cc: $DLIST_CC"
echo "subject: $DESCR1"
echo "$DESCR2"
echo ""
echo "$DESCR3"
echo ""
cat $TMPFILE) | sendmail $DLIST

In the above script the part "cat $TMPFILE" is to be in a different color like blue or red. Please let me know how i could achieve this. I did go through other threads but was not very clear and not able to do it.
Please help and thanks in advance.
# 2  
Old 05-06-2010
try this combination in your script.

Code:
NORMAL=`echo "\033[m"`
FGRED=`echo "\033[31m"`
BGRED=`echo "\033[41m"`
bold=`tput bold`
norm=`tput sgr0`
echo -e " $bold hello $norm"
echo -e " ${FGRED}some text ${NORMAL}"

# 3  
Old 05-06-2010
Hi,

I included the following;

Code:
NORMAL=`echo "\033[m"`
FGRED=`echo "\033[31m"`

(echo "From: $REPLY"
echo "To: $DLIST"
echo "Cc: $DLIST_CC"
echo "subject: $DESCR1"
echo "$DESCR2"
echo ""
echo "$DESCR3"
echo ""
${FGRED} cat $CONNREP ${NORMAL}) | sendmail $DLIST
rm $CONNREP

The above did not work and gave the message as "ksh: ^[[31m: not found"
# 4  
Old 05-06-2010
Create an email like the one you want to send using outlook or thunderbird, etc and send it to your unix system.
Retrieve the email from /usr/spool/mail/recipient (using vi) and use that file as a template for modifying $TMPFILE.
You will see that there are multiple sections in the file, a plain text portion, and an html portion.
White space is important, if there are blank lines near the boundary lines, and the "Content-type" lines, these must be retained.
# 5  
Old 05-06-2010
I am still confused and not able to get it

Hi,

I am not clear and confused. Can someone help me with this requirement.
# 6  
Old 05-06-2010
If the recipient is reading the email using a unix telnet session, then you can use the appropriate terminal escape sequences to change the color.
If the email is being read by a MS Windows email client, then you have to create the email using html tags to change color.
An alternative may be to create a pdf file, and email it as an attachment.
# 7  
Old 05-06-2010
Quote:
Originally Posted by jgt
If the recipient is reading the email using a unix telnet session, then you can use the appropriate terminal escape sequences to change the color.
If the email is being read by a MS Windows email client, then you have to create the email using html tags to change color.
An alternative may be to create a pdf file, and email it as an attachment.
yep even i will suggest the same :-)

go for the tools like txt2pdf or txt2html :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send mail with font color change

Hi All, I have a file that contains following entries. I want to highlight the line that has word as "FAILURE" while sending the email. File ------------------------------------------------------------ Job Name: ABC Start Time: 07/20/2019 07:32:39 End Time: 07/20/2019... (4 Replies)
Discussion started by: sdosanjh
4 Replies

2. UNIX for Beginners Questions & Answers

Shell script to compare text and send a mail

Hello, Somebody can help me to develop a script for the below requirement I have a 3 files in a directory which was dynamically changed everyday basis. I need a script to fetch the 1pattern of strings in each file. if the three matching pattern is same send a mail with subject as success else... (1 Reply)
Discussion started by: MATHANKUMAR
1 Replies

3. Shell Programming and Scripting

Substr/Instr in shell script or extract part of text

Hi, I need to extract part of a text to two variables text is "PL/SQL procedure successfully completed. ERROR ----------------------------------------------------------------- Test Error Message PLUSVAR ---------- 1" I want "Test Error Message" in one variable and "1" in another variable.... (11 Replies)
Discussion started by: vedavrath
11 Replies

4. Shell Programming and Scripting

To display the selected part in text file of unix

0400903071220312 20120322 20:21 1TRANTELSTRAFLEXCAB22032012CMP201323930000812201108875802100A003485363 12122011AUS 182644 000C2 8122011 0000 000 1TRANTELSTRAFLEXCAB22032012CMP201323930000812201108875802100A003485363 12122011AUS ... (6 Replies)
Discussion started by: rammm
6 Replies

5. AIX

How to color text and mail

I want to color the text and bold the text and mail these text. input: hi..(in bold) good morning (in blue color) and mail these as in color and bold :wall: (1 Reply)
Discussion started by: AhmedLakadkutta
1 Replies

6. Shell Programming and Scripting

Perl or Awk script to copy a part of text file.

Hi Gurus, I'm a total newbie to Perl and Awk scripting. Let me explain the scenario, there is a DB2 table with 5 columns and one of the column is a CLOB datatype containing XML. We need all the 4 columns but only a portion of string from the XML column. We decided to export DB2 table to a .del... (26 Replies)
Discussion started by: asandy1234
26 Replies

7. Shell Programming and Scripting

Different color in mail

Hi, The following command i executed mailx -s "hi" abc@yahoo.com<<EOF `echo "^[[31mWelcome"` EOF I don't any color (RED) in my mail. Please assist me? Os is SunOs 5.8 Thanks. (1 Reply)
Discussion started by: shahnazurs
1 Replies
Login or Register to Ask a Question