Operating System - HP-UX
1831321 Members
3014 Online
110023 Solutions
New Discussion

Send both attached file and different file as body.

 
SOLVED
Go to solution
Terrence
Regular Advisor

Send both attached file and different file as body.

I'm currently successfully sending an rtf file as an attachment with the following command.

uuencode summary.rft summary.rtf |mailx -m -s "Summary Report" recipient@destination.org

This is the only way I've been able to send the file as an attachment and have it open in MS Word correctly and without errors.

Unfortunately they now want me to include another file (cover.txt) in the body of the same email. I've searched the forums, but can't find how to do both in the same email.

Suggestions?
3 REPLIES 3
Steven E. Protter
Exalted Contributor
Solution

Re: Send both attached file and different file as body.

Shalom,

The attached script can be modified to do the job.

Normally I send a link but DNS is not working well here today.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Send both attached file and different file as body.

Hi Terrence:

#!/usr/bin/sh
mailx -m -s "Stuff..." whoever@somewhere.com << END
$(ux2dos /etc/hosts | uuencode /etc/hosts)
This is all I care to say!
END

Regards!

...JRF...
Terrence
Regular Advisor

Re: Send both attached file and different file as body.

Wow, talk about prompt answers from two heavy hitters!

Here's the simplified solutions for anyone who might be searching on this issue in the future.

The file to be attached is called summary.rtf, and the file that's going to be in the body is called cover.txt

Steven's solution boils down to this:

uuencode summary.rtf summary.rtf >> cover.txt
cat cover.txt | /usr/sbin/sendmail -t address@address.com

James' solution is as he writes except since I have a file that's going to be the body, a slight change is made. Also James' solution has the advantage of allowing a subject.

mail -m -s "Summary Report" address@address.com << END
$(ux2dos summary.rtf | uuencode summary.rtf)
`cat cover.txt`
END

Gracias Friends!