1755310 Members
3858 Online
108831 Solutions
New Discussion юеВ

Attach a file in mail

 
Alex Galitsky
Occasional Contributor

Attach a file in mail

Hi,

I have to send a PDF file via sendmail or mailx utility
How can I do that?

Thank you
6 REPLIES 6
Corthouts Carlo
Valued Contributor

Re: Attach a file in mail

Hello,

* ux2dos | uuencode | sendmail -v


* ux2dos | uuencode | mailx -s
harry d brown jr
Honored Contributor

Re: Attach a file in mail

uuencode file file1.pdf |mailx -m -s "Heading for email"

It's important to "tag" the uuencoded file as a type PDF so your mail program can read it.

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: Attach a file in mail

Alex,

And to send Mulitple PDF's in an email:

for i in `echo filename1 filename2 filename3 ...`
do
uuencode $i $i.pdf
done|mailx -m -s "test" username@whereever.com


if the filename already has PDF at the end, then drop the ".pdf" after the second $i in the loop.

live free or die
harry
Live Free or Die
Helen French
Honored Contributor

Re: Attach a file in mail

Hi Alex,

Check this thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x19e3ff77de2bd611abd50090277a778c,00.html

HTH,
Shiju

Life is a promise, fulfill it!
Robin Wakefield
Honored Contributor

Re: Attach a file in mail

Hi Alex,

Here's a simple script using sendmail:

=======================================
#!/bin/ksh

if [ $# -ne 3 ] ; then
echo
echo Syntax error: $0 file subject recipient
echo
exit 1
fi

file=$1
subject=$2
recipient=$3

(echo "Subject: $2

Please find file $1 attached";
uuencode $file ${file}.pdf) | /usr/lib/sendmail $recipient
=====================================

this sorts out the Subject, which sendmail expects to start "Subject: " followed by a blank line. It also forces a ".pdf" suffix to the attachment. If your original file already has that as a suffix, then you don't need it.

Rgds, Robin.
Alex Galitsky
Occasional Contributor

Re: Attach a file in mail

Thank you very much -
it's working!

Frankly, I did not expect such generous help.

Thank you again!

Alex