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.
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;
`
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.
Or also:
uuencode $File.$(date).csv <$File.csv | mailx -s "Report $(date)" $Addr
ASKER
No luck. I am still receiving junk, but not an attachment.
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.
Try loading mimetools on your server and MIME encode the CSV file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
Try this:
cat $File.csv | uuencode $File.$(date).csv | mailx -s "Report $(date)" $Addr