Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2003-11-17
8
Medium Priority
?
4,975 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 750 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
Suggested Courses

618 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