Message Body while sending an email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Message Body while sending an email
# 1  
Old 11-25-2015
Message Body while sending an email

I am making use of the following code to display the results of my txt file in an email:

Code:
mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt

Email Output:
Code:
----------Query 1 Count Validation Results--------
Source count is 4
Target count is 3
Source and Target query counts DO NOT match

When I am trying to incorporate the message body, its not working as expected

Code:
echo " "########COUNT VALIDATION RESULTS FOR `date +%c`########" | mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt

Actual output:
Code:
----------Query 1 Count Validation Results--------
Source count is 4
Target count is 3
Source and Target query counts DO NOT match
########COUNT VALIDATION RESULTS FOR Wed 25 Nov 2015 11:08:37 AM CST########

My desired output is:
Code:
########COUNT VALIDATION RESULTS FOR Wed 25 Nov 2015 11:12:29 AM CST########
----------Query 1 Count Validation Results--------
Source count is 4
Target count is 3
Source and Target query counts DO NOT match

Any help is really appreciated.

Thanks,
R
# 2  
Old 11-25-2015
Code:
{
        echo "########COUNT VALIDATION RESULTS FOR $(date +%c) ########"
        cat Count_Validation_Results_$(date +%m%d%Y).txt
} | mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com

# 3  
Old 11-25-2015
Quote:
Originally Posted by Yoda
Code:
{
        echo "########COUNT VALIDATION RESULTS FOR $(date +%c) ########"
        cat Count_Validation_Results_$(date +%m%d%Y).txt
} | mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com

Sorry..Its not working
# 4  
Old 11-25-2015
Quote:
Originally Posted by ronitreddy
Sorry..Its not working
We're sorry it is not working too. It you tell us what operating system and shell you're using AND tell us what did happen when you tried Yoda's suggestion, we might be able to help you make it work.

Am I correct in assuming that you're not using a shell that understands Bourne shell syntax?
# 5  
Old 11-25-2015
Quote:
Originally Posted by Don Cragun
We're sorry it is not working too. It you tell us what operating system and shell you're using AND tell us what did happen when you tried Yoda's suggestion, we might be able to help you make it work.

Am I correct in assuming that you're not using a shell that understands Bourne shell syntax?
Code:
uname -a
Linux xldetl01 2.6.18-194.32.1.el5 #1 SMP Mon Dec 20 10:52:42 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

I am using bash script.sh to execute my bash script.

Please let me know if you need further info.

Thanks
# 6  
Old 11-25-2015
And...
What errors did bash print, if any?

What was in the mail that was sent?

What output do you get from the command:
Code:
od -bc script.sh

# 7  
Old 11-25-2015
Quote:
Originally Posted by Don Cragun
And...
What errors did bash print, if any?

No errors.

What was in the mail that was sent?

########COUNT VALIDATION RESULTS FOR Wed 25 Nov 2015 03:56:39 PM CST ######## cat Count_Validation_Results_11252015.txt

I used the following code
Code:
echo "########COUNT VALIDATION RESULTS FOR $(date +%c) ########" cat Count_Validation_Results_$(date +%m%d%Y).txt | mail -s 'Count Validation Test Comparison Results' RONIT@XYZ.COM

What output do you get from the command:
Code:
od -bc script.sh

I have attached the file "test.txt"

Last edited by ronitreddy; 11-25-2015 at 05:59 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Sending email with message body and attachment

Hello experts!! I am trying to send an email with message body and attachment.but i am getting any one like message body or attachment. I tried below command: (echo "subject:test";echo "MIME-Version: 1.0";echo "content-transfer-encoding:base 64";echo "content-type:txt;name=test.txt";cat... (2 Replies)
Discussion started by: Devipriya Ch
2 Replies

2. Shell Programming and Scripting

Sending sql output to email body with conditional subject line

hi , i have written below piece of code to meet the requirement but i am stuck in the logic here. the requirement are: 1) to send the sql out put to email body with proper formatting. 2) if count_matching = Yes then mail should triggered with the subject line ... (10 Replies)
Discussion started by: itzkashi
10 Replies

3. Shell Programming and Scripting

Body content is in random format while sending email from Linux to my outlook.

Hi I have a script running in lunix machine which emails log file content to my outlook. Here is the actual log file result: Image-1 In-Master:25028 ReplicaDn Consumer Supplier Delay dc=xxx,dc=com lmjker0110:12345 ... (4 Replies)
Discussion started by: buzzme
4 Replies

4. Shell Programming and Scripting

[Solved] Cant get message body

Hi guys . I am trying to take the output of top command and mail it to myself . The code is : echo ############################################################## /usr/local/bin/top c n 1 b >> /export/home/top-output.txt echo ############################################################## ... (6 Replies)
Discussion started by: Junaid Subhani
6 Replies

5. Shell Programming and Scripting

Sending an email with a body and attachments using uuencode

Hi, Im having a bit of an issue with using the uuencode command and sending out an email. My aim is to send an email out which has a body and also have attachments. Currently I can either get one or the other and not both on the same email. uuencode... (4 Replies)
Discussion started by: 02JayJay02
4 Replies

6. UNIX for Dummies Questions & Answers

Sending email with attachment and body

Hi I want to able to attach a file to a email and send it with a body the body of the email is within the "body" file, and the attachment in "atch" if i send like below it will send the email correctly /usr/sbin/sendmail me@you.com< body And when i send the attachment alone... (3 Replies)
Discussion started by: sridanu
3 Replies

7. UNIX for Dummies Questions & Answers

Mailx empty body message

Hi, Is there a way to suppress this message? Null message body; hope that's ok My email string is: mailx -s "This is my subject" myemail@domain.com < /dev/null It's just an annoyance to me that I would like see go away. (3 Replies)
Discussion started by: bbbngowc
3 Replies

8. Shell Programming and Scripting

Not able to attach text in body of email while sending mail with attachment

Hi, We have been trying to send mail with attachment and it is going fine, but when we try to attach a text to the body of the email, we find that the mail is going fine with the body text but the attachment is not going through. We are using ksh. The command that is successfull without the... (6 Replies)
Discussion started by: jmathew99
6 Replies

9. Shell Programming and Scripting

Sending email message in colour and bold letter

The code echo -e "\033[34m Test \033[0m Mail" when i execute this command line i get proper output but when i mail the output of this command through sendmail it doesn't appear. Basically I want to send email message in diffrent colours, bold letter using shell script. (2 Replies)
Discussion started by: baps
2 Replies

10. UNIX for Advanced & Expert Users

sending mails with attachment and also some text in mail body

Hi, Can some one help me with the syntax of the mailx that should send an attachment and also some text in the message body together. When I am using the following syntax it is not sending the attachment but only the message body. unix2dos -ascii $REPORTFILE | uuencode $PCFILE | mailx -s... (7 Replies)
Discussion started by: guptan
7 Replies
Login or Register to Ask a Question