sending attachments in mail

Hi ,

i have tried the following command to send an email with an attachment
its working fine but i am getting mail with the embeded content inside the mail that too truncated.

i wanted it as an attachment.

/usr/lib/sendmail -F "MAC SIA" address "rajendra@abc.com.sg" -t < /prod/applc/ds_data/mac/working/nullctry.txt

regards
Rajesh

Hi, for that you could use "uuencode" and "mail" commands:

(cat text.txt; uuencode /prod/applc/ds_data/mac/working/nullctry.txt /prod/applc/ds_data/mac/working/nullctry.txt) | mail rajendra@abc.com.sg

Assuming that:

  • text.txt contains the body of the email, so this is optional.
  • /prod/applc/ds_data/mac/working/nullctry.txt is the file you want to attach.

Hi grail,

i have used both the scripts

(cat nullctry.txt; uuencode /prod/applc/ds_data/mac/working/nullctry.txt /prod/applc/ds_data/mac/working/nullctry.txt) | mail RajendraP_Gora@abc.com.sg

and also

(cat nullctry.txt; uuencode nullctry.txt </prod/applc/ds_data/mac/working/nullctry.txt ) |
mail RajendraP_Gora@abc.com.sg

i could get the attachment. the problem is the lines are continious
for eg

   the original is   1,2,3,4
                        a,b,c,d
                        x,y,z,i

but in mail the attachment is like this 1,2,3,4a,b,c,dx,y,z,i

thanks for your response

Reagards
Rajesh

what is the need for seperate cat and then to use uuencode for that..

if your file is content

then use it as

uuencode content content.txt and then with mail -- this should work

Rajendra

Do you mean that the contents of the original attached file varies from that you got in the mail? If your answer is yes, I am surprised. What I have used for this purpose is the one given below and always I used to get the file as it is.

uuencode FileNameWithPath "AttachmentName" | mailx -s "MailSubject" MailAddress

For example If I send the File abcd.xls as

uuencode /home/usr/bb/abcd.xls "AttendanceList.xls" | mailx -s "List Of Attendance" rajendra@yahoo.com

Then the file abcd.xls will be attached in the mail with the name AttendenceList.xls and the mail subject will be - List Of Attendance.

Hope this helps.
Thank you

Thanks a lot bobby it works fine for csv :slight_smile:

i changed it to csv and it works fine . but for txt same problem

any way my problem is resolved thanks a lot

Regards
Rajesh

When i sent with an attachment(text file), the format for my text file is incorrect. Some of the fields went to the next line. I have already changed unix2dos.If i use EditPlus or UltraEdit to open this file, the format is what i want.How can i ensure that the text file is long enough to contain the format that i want ?

unix2dos -ascii $sqloutfile $emailoutfile