Solved

How do I attach a .csv file in UNIX to an email message to send out

Posted on 2003-11-17
8
3,806 Views
Last Modified: 2007-12-19
I am attempting to use UNIX to send an email message.  With this email message I would like to send an attachment. Can this be done?  Currently I am using the following code:
mailx -s $Submsg3 $Email_Recip < ${SQL_FIL}

The problem that I am having is that the sql file is part of the body of the email and I would like it to be an attachment of the email.  Thank you for your help with this.
0
Comment
Question by:wrigh066
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 9767479
uuencode $SQL_FIL | mailx -s $Submsg3 $Email_Recip

or if you have a mail client like mutt or pine, you can MIME encode and email the attachment using their options.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9768019
if u do not have uuencode installed then try this.
create a tar fir attachement.
tar cvf - attachment  | gzip - > attachment.tar.gz
attachment.tar.gz | mail -s "this is the subject" me@mymail.com
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9768028
also read this post, u can get the code for sending attachement from here.
http://www.experts-exchange.com/Operating_Systems/Linux/Q_20786839.html
0
 
LVL 38

Expert Comment

by:yuzh
ID: 9768163
If you want to the Windows Mail client to get the attachment properly, use:

mpack/munpack  (MIME equivalent of uuencode/uudecode, )
or
m[un]ack - mmencode - metamail
or
mattasend
or
mutt

to send the email with attachment

eg:
echo "hello" | mutt -a file.gz -s "logs" user@address.com

http://oldlook-search.experts-exchange.com/Operating_Systems/Linux/Linux_Administration/Q_20591693.html

For Solaris you can download these tools from:
http://sunfreeware.com/
PS: for Solaris, you can also use dtmail

man mutt
man mattasend
man mpack

to learn more.

You can also use "uuencode" to do the job, but soem of the Windows mail client might not be
able to handle the attachment, you have to save the email and then transfer it to a UNIX box
to uudecode to get the attachemet.

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 9769913
to complete yuzh's comment:
  i.g. standard UNIX programs cannot create a MIME-compliant attacjment in mails, even the suggested uuencode method does not.

All mail and mailx programs I know cannot do it. Most others can, for example:

metasend -t user@some.where -s metasend -f file -b -m text/plain -e base64
pine user@some.where -attach file -I^X
elm -s ok user@some.where -A y
echo "body"| mutt -a y -s mutt user@some.where
echo "attached file: xxx.txt"|uuenview -b -a -m user@some.where -s subjet file-attachment
0
 
LVL 1

Accepted Solution

by:
mateinone earned 250 total points
ID: 9891867
uuencode can work fine

simply

uuencode test.csv test.csv|mail whoever@wherever.com

Will send any file as an attachment

you just need to check the format
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9892794
uuencode .. | mail ..
does not send attachements, except if you have a special version of mail
0
 
LVL 1

Expert Comment

by:mateinone
ID: 9979952
Then we must, and so must a fair few of our customers, as we use it on a regular basis. Also know of others doing the same thing. We were struggling with this also, eventually found the uuencode solution on a forum somewhere, and it worked a treat for us.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now