Solved

Need to attach files to email in ksh

Posted on 2009-07-09
14
522 Views
Last Modified: 2013-12-26
hi:

I need to attach two files -  .xls and .html extensions - to an email. I have the following code :

mail -s "Files for the month" tom.dick@harry.com < file1.html
How can I accomplish this?
0
Comment
Question by:LuckyLucks
  • 6
  • 5
  • 3
14 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24817501

Hi,
you could  'mutt', which has the builtin capability of sending attachments (using MIME) -

echo "This is a body text" | mutt -a file1.html -s "Files for the month" tom.dick@harry.com
mutt can send CC (-c option) and BCC (-b option), too.
wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24817530
... with two files (sorry, saw that requirement too late)
echo "This is a body text" | mutt -a file1.html -a file2.xls -s "Files for the month" tom.dick@harry.com
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24817561
if you have zip command then try

zip myattachment.zip *.xls *.html
uuencode myattachment.zip myattachment.zip | mail -s "Files for the month" tom.dick@harry.com
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:LuckyLucks
ID: 24818047
woolmilkproc:

I am getting mutt not found. I guess we do not have this mail client. Can we accomlish the same with mail?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24818059
what os do you run?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24818072
What is your OS? You can get mutt for almost any platform!
0
 

Author Comment

by:LuckyLucks
ID: 24818236
unix aix
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24818283
OK,
find mutt on the AIX toolbox CD which came with your system, or here
http://www-03.ibm.com/systems/power/software/
Just click 'Alphabetical ...', download mutt and install with 'rpm -i ...'
wmp
 
 
 
0
 

Author Comment

by:LuckyLucks
ID: 24818333
I can not download softwares onto the AIX boxes. This is administered by admins and they will likely not install anything on my profile or company wide. Any other idea?


BTW omar I dont have zip either.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24818399
OK,

so you will have to rely on uuencode and e.g. 'tar'

tar -cvf monthfiles.tar file1.xls file2.html
uuencode monthfiles.tar monthfiles.tar | mail -s "Files for the month" tom.dick@harry.com

Note however, that 'tar' must exist at the target system!


0
 

Author Comment

by:LuckyLucks
ID: 24823895
Can I add a body test by expanding it as :

tar -cvf monthfiles.tar file1.xls file2.html
uuencode monthfiles.tar monthfiles.tar | mail -s "Files for the month" -b "Please open the attachment with winzip.\n Contents include three files: 1) file1 2) file2"  tom.dick@harry.com
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24823966
There is no -b flag with 'mail'
What is it supposed to do? Make up a body? That's unfortunately not possible.
What you could try (I never used it and have no time to test now -

tar -cvf monthfiles.tar file1.xls file2.html
uuencode monthfiles.tar monthfiles.tar  > attach.txt
echo "Please open the attachment with winzip.\n Contents include three files: 1) file1 2) file2" > body.txt
cat body.txt attach.txt | mail -s "Files for the month" tom.dick@harry.com
wmp
0
 

Author Comment

by:LuckyLucks
ID: 24824513
Tis doesnt attach the attachment i.e attach.txt , simply sends out an email with the bosy
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 24825037
I think it is not possible to send body along with attachments ! I think many zipping s/w can untar tar files
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question