Solved

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

Posted on 2003-11-17
8
4,366 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
Technology Partners: 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 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

738 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