Ok, I've given this a bit of thought and played a bit on my test machine and heres what I find:
Test system = RH Linux, MTA = Sendmail, client mailer = Outlook on Win2K.
I generated a Excel (test.cvs) file and attached it to a mail to a user on my linux box, sent the mail to the user.
On the Linux server as root I read the file /var/spool/mail/username in that file I had the following:
START MAIL
+++++++++++++++++++++++++++++++++++++++++++++++++
From me@mymail.co.uk Mon Sep 8 21:02:33 2003
Return-Path: <me@mymail.co.uk>
Received: from testpc (me.fredbloggs.co.uk [xxx.xxx.xxx.xxx])
by mytest.server.com (8.9.3/8.9.3) with SMTP id VAA09252
for <username@hisdomain.co.uk>; Mon, 8 Sep 2003 21:02:31 +0100
From: "Laurie" <me@mymail.co.uk>
To: "MR Tester" <username@hisdomain.co.uk>
Subject:
Date: Mon, 8 Sep 2003 21:05:47 +0100
Message-ID: <LPBBIINFNJDFEAFPCKDKMEIKCKAA.username@hisdomain.co.uk>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_001C_01C3764C.F9C49D30"
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Importance: Normal
X-OW-MailScanner: Found to be clean
This is a multi-part message in MIME format.
------=_NextPart_000_001C_01C3764C.F9C49D30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Laurie Baker
IT Consultant
Information contained in this e-mail and any attachments is confidential and
intended for the use of the addressee only. Dissemination, distribution,
copying or use of this communication without prior permission of the
addressee is strictly prohibited. If you have received this transmission in
error, please advise the originator by reply e-mail and delete it. Thank
you.
------=_NextPart_000_001C_01C3764C.F9C49D30
Content-Type: application/octet-stream;
name="TEST.csv"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="TEST.csv"
1,11,35,578,3465,44,1,9
578,578,1,578,1,578,578,578
11,4,85,356,1,234,33,345
------=_NextPart_000_001C_01C3764C.F9C49D30--
++++++++++++++++++++++++++++++++++++++++++++++++++++
END MAIL
So as you will see the attached file TEST.csv is clear in teh mail message so in this case its just a case of chopping out the bit you want and saving it to a file (you could have your data team add a row at the top and bottom to give your awk, sed or perl script identify the attachment start/finish perhaps.
NOW, if the mail is sent to you from a Unix system like the following: uuencode test.cvs test.cvs |mail -s "todays data" username@hisdomain.co.uk, then you will have an encoded attachment that would look something like:
+++++++++++++++++++++++++++++++++++++++++++++++++++
From: Root <root@myserver.com>
Message-Id: <200309081916.UAA07239@myserver.com>
To: username@hisdomain.com
Subject: TEST
Status: RO
begin 664 test.sql
M(R!->5-13"!D=6UP(#@N,30*(R!486)L92!S=')U8W1U<F4@9F]R('1A8FQE
M("=E;G1R:65S)PI#4D5!5$4@5$%"3$4@;7ET97-T("@*("!I9"!I;G0H,3$I
M($Y/5"!.54Q,(&%U=&]?:6YC<F5M96YT+`H@('1I=&QE('9A<F-H87(H-C`I
M(&1E9F%U;'0@3E5,3"P*("!T97AT(&)L;V(L"B`@9&%T92!D871E=&EM92!D
M969A=6QT($Y53$PL"B`@4%))34%262!+15D@("AI9"D**2!465!%/4UY25-!
M33L*(R!$=6UP:6YG(&1A=&$@9F]R('1A8FQE("=E;G1R:65S)PI)3E-%4E0@
M24Y43R!M>71E<W0@5D%,5453("@Q+"=P87!E<B<L)T-U=',@<W1O;F4G+"<R
M,#`R+3`T+3`Q(#$P.C(S.C,Q)RD["DE.4T525"!)3E1/(&UY=&5S="!604Q5
M15,@*#(L)TQI;G5X(&%N9"!!<&%C:&4G+"=)(&AA=F4@9&ES8V]V97)E9"!T
M:&%T($QI;G5X(&%N9"!!<&%C:&4@87)E('-H:6YI;F<@97AA;7!L97,@;V8@
M3W!E;B!3;W5R8V4@<')O:F5C=',N)RPG,C`P,BTP-"TP,R`Q,3HP,SHU,B<I
M.PI)3E-%4E0@24Y43R!M>71E<W0@5D%,5453("@S+"=097)L)RPG4&5R;"!I
M<R!G<F5A="<L)S(P,#(M,#0M,#4@,38Z,3,Z,C(G*3L*24Y315)4($E.5$\@
M;7ET97-T(%9!3%5%4R`H-"PG0T=)(&%N9"!M;V1?<&5R;"<L)U=A>2!T;R!G
M;R$N)RPG,C`P,BTP-"TP."`Q,CHT,SHR-B<I.PI)3E-%4E0@24Y43R!M>71E
M<W0@5D%,5453("@U+"=02%`@:7,@8V]O;"$G+"=,96%R;FEN9R!02%`@:7,@
M=&AE(&)E<W0@=&AI;F<@=&AA="!)(&1I9"!T;V1A>2XG+"<R,#`R+3`T+3$V
-(#`X.C$Y.C(X)RD["@``
`
end
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Then you would do as you would before chop out the attachment part save it as a text file (in this case test.txt) then do: uudecode -o test.sql test.txt
This will give you a file called test.sql that looks like:
# MySQL dump 8.14
# Table structure for table 'entries'
CREATE TABLE mytest (
id int(11) NOT NULL auto_increment,
title varchar(60) default NULL,
text blob,
date datetime default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
# Dumping data for table 'entries'
INSERT INTO mytest VALUES (1,'paper','Cuts stone','2002-04-01 10:23:31');
INSERT INTO mytest VALUES (2,'Linux and Apache','I have discovered that Linux an
d Apache are shining examples of Open Source projects.','2002-04-03 11:03:52');
INSERT INTO mytest VALUES (3,'Perl','Perl is great','2002-04-05 16:13:22');
INSERT INTO mytest VALUES (4,'CGI and mod_perl','Way to go!.','2002-04-08 12:43:
26');
INSERT INTO mytest VALUES (5,'PHP is cool!','Learning PHP is the best thing that
I did today.','2002-04-16 08:19:28');
===========================================
Sorry about the content it's just test data.
Well I hope that gives you a starting point?
It should'nt be to hard to script what you need.
Good Luck,
Laurie