Solved

Emailing file as an attachment

Posted on 2006-07-13
12
389 Views
Last Modified: 2013-12-26
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.
0
Comment
Question by:csreeni
12 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 17103115

Try this:

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


0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 17103134

Or also:

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

0
 

Author Comment

by:csreeni
ID: 17103928
No luck. I am still receiving junk, but not an attachment.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 48

Expert Comment

by:Tintin
ID: 17104254
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.
0
 
LVL 38

Accepted Solution

by:
yuzh earned 250 total points
ID: 17104976
For M$ PC mail client, it is better to use mutt to do the job, you can download the
binary package from:
http://hpux.cs.utah.edu/hppd/hpux/Networking/Mail/mutt-1.5.11/

If you use uuencode to send the mail, at the other end, the user has to save the mail as a file and then use uudecode to extract the attachmemt.

Please read the answer in http:Q_20305167.html  to learn more details.
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 17107878

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

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



0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 17107885

Or this:

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

Expert Comment

by:MikeOM_DBA
ID: 17109489

Or even this:

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

Expert Comment

by:rockiroads
ID: 17121083
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

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 147
unable to delete all specified values regedit 38 574
MaxSpan challenge 9 106
Line meaning 9 88
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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