Solved

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

Posted on 2003-11-17
8
4,045 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

770 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