Mail Attachment : What am I doing wrong ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Mail Attachment : What am I doing wrong ?
# 1  
Old 03-04-2007
Mail Attachment : What am I doing wrong ?

Ok, I have read so many threads here but still can't figure out what I am doing wrong.

When I type the following on the Unix prompt it works perfectly fine.

uuencode attach.txt attach..html | mail -s "My Subject" me@somewhere.com

But if I put it in a file like below and execute it:-
------------------------------------------------------------------------
#!/bin/ksh

uuencode attach.txt attach..html | mail -s "My Subject" me@somewhere.com
------------------------------------------------------------------------
The attachment comes inside the body of the email unreadable like below:

begin 660 attach..html
M/'!R93X*1413(%)E;&%T:6]N86P@0V]N=F5R<VEO;B!5=&EL:71Y("T@5F5R
M<VEO;B!6,2XR"@IE9'-R8V]N=B!(87,@<W1A<G1E9#H@5&AU($UA<B @,2 Q
M.#HP-3HQ-2 R,# W"B */CX^($DP,#H@26YI=&EA;&EZ871I;VX@0V]M<&QE
M=&4@/#P\"CX^/B!),#$Z(%1/5$%,($-/3E9%4E-)3TX@4D5#3U)$4R!214%$
M.B R.#0Y-2 \/#P*/CX^($DP,CH@5$]404P@4D]74R!74DE45$5.(%1/(%1!

Any help is appreciated.
Thanks.
# 2  
Old 03-04-2007
Quote:
Originally Posted by Kartheg
Ok, I have read so many threads here but still can't figure out what I am doing wrong.

When I type the following on the Unix prompt it works perfectly fine.

uuencode attach.txt attach..html | mail -s "My Subject" me@somewhere.com

But if I put it in a file like below and execute it:-
------------------------------------------------------------------------
#!/bin/ksh

uuencode attach.txt attach..html | mail -s "My Subject" me@somewhere.com
------------------------------------------------------------------------
The attachment comes inside the body of the email unreadable like below:

begin 660 attach..html
M/'!R93X*1413(%)E;&%T:6]N86P@0V]N=F5R<VEO;B!5=&EL:71Y("T@5F5R
M<VEO;B!6,2XR"@IE9'-R8V]N=B!(87,@<W1A<G1E9#H@5&AU($UA<B @,2 Q
M.#HP-3HQ-2 R,# W"B */CX^($DP,#H@26YI=&EA;&EZ871I;VX@0V]M<&QE
M=&4@/#P\"CX^/B!),#$Z(%1/5$%,($-/3E9%4E-)3TX@4D5#3U)$4R!214%$
M.B R.#0Y-2 \/#P*/CX^($DP,CH@5$]404P@4D]74R!74DE45$5.(%1/(%1!

Any help is appreciated.
Thanks.
What you see is the attachment as encoded data.

Your email client is supposed to recognize this as an attachment, to decode it automatically and present it as an attachment..
E.g. Mailx is not capable to recognize the attachment. You would have to save the email to a file and then run uudecode on that file.

Are you using the same "to" email address when executing the command on the command line or from within the script?

Is there a blank line between the email headers and the line "begin 660 attach..html"?

Is the last line of the email "end"?
# 3  
Old 03-04-2007
Yes I am using the same TO e-mail. I cut and pasted in Unix prompt.

The e-mail I recieved has blanks in the TO & Subject fields when I ran the script. From the UNiX prompt is perfect.

Yes there is an End. The other option I have is to put the content as the body, but still there is problem cause the contents are not treated as text and it comes out wierd.

M(" @(" @(" @(" @(" @*BHJ*BHJ*BHJ*@HJ*BHJ*BHJ*BHJ*BHJ*BHJ(" @
M(" @(" @(" @(" @(" @("HJ*BHJ*BHJ*BHJ*BHJ*BH**BHJ*BHJ*BHJ*BHJ
I*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ"@HJ

end
# 4  
Old 03-04-2007
Quote:
Originally Posted by Kartheg
Yes I am using the same TO e-mail. I cut and pasted in Unix prompt.

The e-mail I recieved has blanks in the TO & Subject fields when I ran the script. From the UNiX prompt is perfect.

Yes there is an End. The other option I have is to put the content as the body, but still there is problem cause the contents are not treated as text and it comes out wierd.

M(" @(" @(" @(" @(" @*BHJ*BHJ*BHJ*@HJ*BHJ*BHJ*BHJ*BHJ*BHJ(" @
M(" @(" @(" @(" @(" @("HJ*BHJ*BHJ*BHJ*BHJ*BH**BHJ*BHJ*BHJ*BHJ
I*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ"@HJ

end
Try "mailx" instead of "mail"
# 5  
Old 03-04-2007
Yes it works

Yes, works perfect now.

Thanks very much.

Kartheg.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Excel attachment in e-mail

i am trying to get an SQL output into an excel attachment and the other output into mail body as excel format. i am getting the excel format in the mail body, but i am not getting the excel attachment. and the output is coming in one cell in the excel. is it possible to get the excel output with... (11 Replies)
Discussion started by: maddelav
11 Replies

2. Shell Programming and Scripting

Mail attachment

Hi, I want to send an attachment and content in a single mail using unix command can anyone pls help me? Thanks Naveen A (6 Replies)
Discussion started by: Pranaveen
6 Replies

3. Shell Programming and Scripting

Getting mail with no Attachment

Hi All, my requirement send a mail with attachment a abc.txt file. below is the shell script. #!/usr/bin/ksh set -x #DIR=/appldata/download/mail MAILTO="krupa.behera@kk.com" SUBJECT="Report" BODY="Hi All," ATTACH=/projects/psoft/hrdw/pushreports/crons/temp_out... (5 Replies)
Discussion started by: krupasindhu18
5 Replies

4. Shell Programming and Scripting

Mail Attachment...

Hi All, I am new to unix. I have written the script to identify the delimiter count for my source file and the output I have to capture in another file and that file should sent to mail with attachment. I have tried to send the attachment with below script . But I am not able to do that. Any... (2 Replies)
Discussion started by: suresh_target
2 Replies

5. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

6. Shell Programming and Scripting

Mail attachment with unix mail

Hi Could someone help me with the details on how to send an attachment through mail in unix. I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps. Regards Ajay (2 Replies)
Discussion started by: ajaykumarboyana
2 Replies

7. UNIX for Advanced & Expert Users

mailx commannd - Mail and Attachment in same mail

Hi , I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Discussion started by: sharif
6 Replies

8. Shell Programming and Scripting

mail with attachment

Hi, I am facing an issue while sending a mail from unix with attachment.the issue is i am able to send a mail with attachment but...after receiving the mail if u see that the text is continous though it was line by line in original.. UUENCODE is the cmd i am using... plz help me in this... (1 Reply)
Discussion started by: param786
1 Replies

9. UNIX for Dummies Questions & Answers

mail attachment

This question has been asked many time before. I did search other questions. But was not able to work out. Really sorry for repeating the same question. I have mail and mailx and sendmail installed. It Tried this uuencode FILENAME.txt FILENAME.txt | mail mymail@yahoo.com the attachment... (3 Replies)
Discussion started by: sushrut
3 Replies
Login or Register to Ask a Question