Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send multiple attachments in a single email 1

Status
Not open for further replies.

guzler

Technical User
May 28, 2003
10
US
Hello,

I need to send as many files as attchments in a single email. I have used

(uuencode file1.txt file2.doc; uuencode file2.txt file2.doc) | mailx -s 'Test' name@email.com

Here I am passing the entire uuencode(whatever is in the bracket) as one string from a pl/sql program .. how do I do it ..

Any help is highly appreciated ..
 
You need "matt".

Source code can be found here: ftp://ftp.riverdrums.com/pub/matt/

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
You've answered your own question. Maybe I don't understand your question.

If you have a bunch of files to be sent as attachments, you just uuencode them all. Say you have a directory full of files you want to send. Say they all end with the extension .txt. You would send them all in the same email as follows...
Code:
#!/bin/ksh

export TOADDR=name@email.com
export FROMDIR=/somedir

cd ${FROMDIR}

( cat <<-TEXT
Hi,

Please find enclosed all of the text files found
in the directory ${FROMDIR} as of $(date).

Sincerly, $(grep $(whoami) /etc/passwd| cut -d: -f5)
TEXT

for FNAME in *.txt
do
   uuencode ${FNAME} ${FNAME}
done
) | mailx -s &quot;${FROMDIR}/*.txt as of $(date)&quot; ${TOADDR}
This example exen gives a nice little message along with the email.

Hope this helps.

 
SamBones

If I want to pass (uuencode file1.txt file1.doc uuencode file2.txt file2.doc) in an argument how will I do it ..

for example my script will look like this ..

#!/usr/bin/ksh

arg1='uuencode file1.txt file1.doc; uuencode file2.txt file2.doc'

($arg1) |mailx -s 'Test' name@email.com

But this does not work .. What am I doing wrong ?

Can you pls help me ..

Thanks,
 
You need to export [tt]arg1[/tt]. The parenthesis spawns a subshell to do the commands in them, so variables need to be exported to be useable in the subshell. Try the following...
Code:
#!/usr/bin/ksh

export ARG1='uuencode file1.txt file1.doc; uuencode file2.txt file2.doc'

($ARG1) | mailx -s 'Test' name@email.com
I haven't tested it, but I think this is what's happening.

Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top