Script needed which will send a mail with attachment files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script needed which will send a mail with attachment files
# 1  
Old 09-25-2007
Script needed which will send a mail with attachment files

Hello,

I need a shell script which need to send a mail with 4 *.csv files as attachments.Anybody can help me?

At present i have a script which is sending only one file as attachments.But i need a script which send 4 files in a shot.

#!/bin/ksh


/bin/mail xxxx@xx.xom << EOF
Subject: Test
To: "xxxx@xx.xom"
MIME-Version: 1.0
Content-Type: Multipart/Mixed; boundary="MY_LONG_BOUNDARY_LINE"

--MY_LONG_BOUNDARY_LINE

`/usr/bin/cat mail_body.txt`

--MY_LONG_BOUNDARY_LINE
Content-Type: text/plain; charset=us-ascii; NAME=zzz.csv;
Content-transfer-encoding: x-uuencode

`/usr/bin/uuencode /fullpath/zz.csv zz.csv`

--MY_LONG_BOUNDARY_LINE--

EOF

Any help will be appreciated.

Thanks
K
# 2  
Old 09-26-2007
Start your exploration here:

https://www.unix.com/how-do-i-send-email/
# 3  
Old 09-26-2007
Quick work-around would be to tar the files and sent the tar-file as the attachment.

HTH Smilie
# 4  
Old 11-24-2007
here u go the script to send mail with attachment

EMAIL="Email@address.com"
MSG="Message:BODY of the Text"
echo "$MSG"
echo "Mail Sent to $EMAIL"
uuencode Path/to/file.csv file.csv>msg.csv
echo "$MSG">msg

cat msg msg.csv >email.msg

mailx -s "Test Email" $EMAIL <email.msg
rm msg
rm email.msg
# 5  
Old 11-24-2007
You can create a single attachment from any number of files to attach:

1. tar all the attachments
2. uuencode the tar-file
3. sed the output of uuencode attached to the mail.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send Mail With Attachment

Hi, I need to send attachment with email as external attachment. Presently, we are using uuencode to make an attachment but it is going as content of body. We are using below command. uuencode "filename1" "filename2" | mailx -r "$SENDFROM" ${SENDTO} In unix box, -a is not supportable... (1 Reply)
Discussion started by: vamshi929
1 Replies

2. Shell Programming and Scripting

Send mail as attachment

Hi All, I am trying to send mail via unix and attaching file along with that mail, but facing issue while sending. I have tried below commands- 1)- uuencode $prmDirOutput/report_mailbody $prmDirOutput/report_mailbody | mailx -s "Acknowledgment file- $subject" $email_id 2)- mutt -a... (4 Replies)
Discussion started by: Amit786
4 Replies

3. Shell Programming and Scripting

Send mail using attachment

Hi All, I need to send mail with attachment. I am using uuencode but it seems it is sending encoded file. I am getting the mail with attachment but there is no data even the file size is almost 90KB. Please help. Thanks. (3 Replies)
Discussion started by: unankix
3 Replies

4. AIX

Need to send attachment in Mail without using uuencode via script in AIX6.1

Dear All, Would some one help me with this to send a file as attachment in a mail using a script without uuencode... I am working on AIX 6.1, the thing is I dont have uuencode available... Is there any other alternate possible way to send file attachment with the mail without using uuencode... (11 Replies)
Discussion started by: msmadhan11
11 Replies

5. Shell Programming and Scripting

How to send mail with attachment in Unix

Hi All, Is it possible to send mail in Unix with attachment. If yes, then how?? (8 Replies)
Discussion started by: parthmittal2007
8 Replies

6. Shell Programming and Scripting

how to run a script using cron job and send the output as attachment via e-mail using unix

how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what... (8 Replies)
Discussion started by: vidhyaS
8 Replies

7. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

8. AIX

Send mail with attachment having csv files

Hi, Could anyone please help me to send multiple files of .csv format in one mail. Thanks Aj (2 Replies)
Discussion started by: atinjain05
2 Replies

9. Shell Programming and Scripting

How to send a mail with attachment?

Hi, I usually write a file TEST.MAIL like this to send mails: Importance: High Priority: Urgent X-Priority: 1 (Highest) From: user Subject: error ... text body .... and then I launch it (or writre a c-chell that launchs it) by writing: mail a@b.com < /users/.../TEST.MAIL How can... (4 Replies)
Discussion started by: albaalbetti
4 Replies

10. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies
Login or Register to Ask a Question