Link to home
Start Free TrialLog in
Avatar of csreeni
csreeni

asked on

Emailing file as an attachment

I am having hard time figuring out how to send an output file as attachment.

My environment:
Generating a sql output - output.csv file
Trying to send it as attachment in outlook mail. Not succeeding. Its sending some junk chars and that too in body of message like:

begin 644 output.200607131533.csv
M14U"05)1("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
@-C<Y,C@P(%5N;"!#86QL<R!4;R!(;VUE($]R($)U<PH@
`
end

OS : HP UX

My shell script looks like :

Connect="report/report
Addr="email@mail.com"
File="output"

sqlplus -s $Connect @report.sql

ux2dos -ascii $File.csv  $File.csv  2>> /dev/null

( uuencode $File.csv $File.$(date).csv
) | mailx -s "Report $(date)" $Addr

Can you guys correct me if I am missing any thing.
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image


Try this:

cat $File.csv | uuencode  $File.$(date).csv | mailx -s "Report $(date)" $Addr



Or also:

uuencode  $File.$(date).csv <$File.csv | mailx -s "Report $(date)" $Addr

Avatar of csreeni
csreeni

ASKER

No luck. I am still receiving junk, but not an attachment.
Avatar of Tintin
Perhaps Exchange is configured to only recognise MIME encoded mail and not uuencoded mail.

Try loading mimetools on your server and MIME encode the CSV file.
ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

I think its the 'date' function, try this:

uuencode  $File.$(date +%YYYYMMDD).csv <$File.csv | mailx -s "Report $(date)" $Addr




Or this:

uuencode  ${File}_$(date +%YYYYMMDD).csv <${File}.csv | mailx -s "Report $(date)" $Addr

Or even this:

uuencode  "$File.$(date).csv" <$File.csv | mailx -s "Report $(date)" $Addr
The comment from yuzh might be worth considering.
I couldnt see much wrong with your syntax, so had a quick check
http://www.shelldorado.com/articles/mailattachments.html

For File attachments with MIME, it recommends using mutt