0
#!/bin/bash
ATTACH1=file.xls<br>
SUBJECT="subj"<br>
FROM=me@domain.com<br>
TO=you@domain.com<br>
CC=them@domain.com<br>
MIME="Application/vnd.ms-excel" <br>
FILE=$ATTACH1<br>
boundary="---my-unlikely-text-for-mime-boundary---$$--" <br>
(cat <<!<br>
From: $FROM<br>
To: $TO<br>
Subject: $SUBJECT<br>
Date: $(date +"%a, %b %e %Y %T %z")<br>
Mime-Version: 1.0<br>
Content-Type: multipart/mixed; boundary="$boundary"<br>
This email has attached the file<br>
--$boundary<br>
Content-Type: $MIME;name="$FILE"<br>
Content-Disposition: attachment;filename="$FILE"<br>
!<br>
uuencode ${ATTACH1} ${ATTACH1}<br>
) | sendmail -v ${TO}<br>
Hi,
The above code can send xls file using shell script. But the problem is that, the received file cant be open. Also, the file size of the xls becomes smaller. Example: original xls attachment size is 17kb before sending, but the received file becomes 378b in size after it was sent..
What can I do to make the xls that was received becomes readable when open by the receiver? What is wrong or missing in the above script? Please help!!!!
And by the way.. I CANNOT USE MUTT
Where are you putting the file content? – a CVn – 2016-01-15T10:43:11.050
you mean the code above? I put it in as script1.sh file then execute it by ./script1.sh – RaymonN – 2016-01-15T10:45:19.683
No, I mean how does the data that gets piped into
sendmail
contain the contents of the file you want to attach to the email? – a CVn – 2016-01-15T10:49:34.343Please see the updated script.. it now sends the same file size but now it contains begin 644 PRB0045758_EDI_UPLOAD_14-01-2016.xls M/#]X;6P@=F5R<VEO;CTB,2XP(C^"CQS<SI7;W)K8F]O:R!X;6QN<SIS<STB M=7)N.G-C:&5M87,M;6EC<F]S;V9T+6-O;3IO9F9I8V4Z<W!R96%D<VAE970B M/@H<W,Z4W1Y;&5S/@H<W,Z4W1Y;&4@<W,Z240](D]R86-L941A=&4B/@H
M<W,Z3G5M8F5R1F]R;6%T('-S.D9O<FUA=#TB9&0O;6TO>7EY>5P@:&@Z;6TZ M<W,B+SX/"]S<SI3='EL93X/"]S<SI3='EL97,^"CQS<SI7;W)K<VAE970@ – RaymonN – 2016-01-15T10:58:31.900
duplicate of http://stackoverflow.com/q/17359/7552
– glenn jackman – 2016-01-15T11:35:44.230no its not duplicate – RaymonN – 2016-01-15T11:40:02.410