12-26-2013
Problem in sending mail with database content
Hi All,
I want to fetch records from Oracle DB table and send it in a mail to a set of users. i.e, I have a query which returns a set of records. I want to send mail with below content:
Hi ,
PFB the details:
<first database record>
<Second database record>
…………….
………………..
…………………..
<n database record>
I am using SPOOL command to get result set from db table in a file result.txt and trying to append it with other text (Hi All,……………. ) and send it in mail.
Below is my code but it just creating a file result.txt with result set from oracle table.
#!/bin/sh
EMAIL="anil.kumar@abc.com"
EMAILMESSAGE="/app/to/path/result.txt"
SUBJECT=" testmail"
echo "Hi," >> $EMAILMESSAGE
echo "PFB the Details:" >> $EMAILMESSAGE
sqlplus -s userid@dbname/pwd<<END
SET HEADING OFF ;
SET NEWPAGE NONE ;
SET FEEDBACK OFF ;
SET WRAP OFF ;
spool /app/to/path/result.txt
select distinct entity_id, fund_name from fi_ss_risk_ctry_dts
where rownum<100;
spool off;
exit;
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
rm /app/to/path/result.txt
Where is my code misbehaving. What can be the problem? Please suggest.
Thanks in advance.
Regards,
Anil
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a problem in sending mail ......
#!/usr/bin/perl -w
$file_length = `cat file.txt | wc -l`;
if ( $file_length == 0) {} else {
`mail -s "Tool" <mymailid> < file.txt`;
}
Eventhough i have used `uuencode Mailfile$App_Server$line | mail <mymailid>`;... (1 Reply)
Discussion started by: vijaysabari
1 Replies
2. UNIX for Advanced & Expert Users
Hi,
I have a problem in sending mail ......
#!/usr/bin/perl -w
$file_length = `cat file.txt | wc -l`;
if ( $file_length == 0) {} else {
`mail -s "Tool" <mymailid> < file.txt`;
}
Eventhough i have used `uuencode Mailfile$App_Server$line | mail <mymailid>`;... (2 Replies)
Discussion started by: vijaysabari
2 Replies
3. UNIX for Dummies Questions & Answers
hi,
I am new to unix.
I need send html content as a mail from my sun-solaris2.6 work station. When I tried that the recipient gets it as html code with all the tags.
any solutions?
thanx in advance (2 Replies)
Discussion started by: gmchoudary
2 Replies
4. Shell Programming and Scripting
i'm a avid fan of making the output of my scripts look pretty. so as a result i put in my scripts a lot of lines that are formed by either ****** or =======
now, outlook seems to have a problem with that. it always removes something that it calls "line breakers" from the emails my scripts send... (5 Replies)
Discussion started by: Terrible
5 Replies
5. AIX
Everytime i try sending mails using the command line have a reply form the daemon saying :
? 1
Message 1:
From MAILER-DAEMON Wed Apr 25 10:42:36 2007
Date: Wed, 25 Apr 2007 10:42:36 -0500
From: Mail Delivery Subsystem <MAILER-DAEMON>
To: malarie
MIME-Version: 1.0
Content-Type:... (0 Replies)
Discussion started by: Netghost
0 Replies
6. UNIX for Dummies Questions & Answers
Im having trouble with sending a file with attachment. The attach file wasn't sent to to the recepient.
We tested this manually and it works but with the script it doesn't work. I'm thinking there is a problem with the script. Here is the code:
mailto=`/dir/dir2/dir3/GET_EMAIL_ADDR.sh... (9 Replies)
Discussion started by: Iq_zero
9 Replies
7. UNIX for Advanced & Expert Users
I am calling a unix script in oracle to send a mail to outlook group using mailx. The cmd looks like this:
mailx -s "AA_BBB_" APPostServices@xyz.com
APPostServices@xyz.com isa group but the mail is not sent
but when i send mail to another group it works fine.
What are the things that i... (1 Reply)
Discussion started by: petervuksich
1 Replies
8. UNIX for Dummies Questions & Answers
Hello all!!
i got a problem in the email content format in outlook which i mail it from a unix.
i want the content to be multiple lines as i see in unix, but the content is grouped into a single line instead in the email content.
The email content is made from tail of a file, and echo... (4 Replies)
Discussion started by: boydunshout
4 Replies
9. Shell Programming and Scripting
Hi, I need to send a email as a txt file and i used the commands,
(echo `echo $EMAIL_MSG` ; uuencode "file.txt" "file.txt" ) | mailx -s "$EMAIL_SUBJECT" "$EMAIL_ID"
I received email with a attachment with all data but i get all of them in one row.
For example:
If file.txt contains value... (1 Reply)
Discussion started by: skcvasanth
1 Replies
10. Shell Programming and Scripting
Hi,
We have a requirement to send multiple attachment(pdf and csv) along with html content in a single mail. For that we are using uuencode. It is working for single pdf attachment and html content. But we are unable to send both pdf and csv attachment with html content. Below is the script.... (5 Replies)
Discussion started by: dholea
5 Replies