email file as attachment...


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users email file as attachment...
# 1  
Old 02-09-2012
email file as attachment...

Hello all,

i am on hp-ux 11.23...i am trying to send an email as an attachement but it dose not seem to work...after reading on google i found that we can use uuencode to send file at attachement...here is my file and the syntax


$ cat test.txt

NAME
---------
TEST

$ uuencode test.txt test.txt | mailx -s "TEST VIEW AUTOMATION" email@domain.com
$

but now here is the problem...i do get and email with subject line as "TEST VIEW AUTOMATION"
but do not get a atttachment...get some garbage (lol) in the body as below...

begin 644 test.txt
M"DY!344@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@"BTM+2TM+2TM
M+2`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@"D--1$)44U0@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
4("`@("`@("`@("`@("`@("`@"@H@
`
end



so what am i doing wrong here ??
# 2  
Old 02-09-2012
You are making the entire body of the email, the attachment. If you edit the received email and input the body to uudecode, you will get your original text.
Search "email attachment" in this forum, there are lots of examples.
# 3  
Old 02-09-2012
Here's an example I did for some folks at work (ksh on Solaris). It sends the same file as 2 attachments just to show how it's done.

Create a text file by doing this:
Code:
 
who > example.txt

then run this script called mailtest:
Code:
 
#!/bin/ksh
##
##  mailtest - example to show how to do attachments.
##
 
# set the body of the message.
MAILBODY="This is the body of the e-mail"
 
# If an ascii file, convert CR/LF so it will open properly in Outlook.
unix2dos -437 -ascii example.txt attach.out
 
(print $MAILBODY; uuencode attach.out example.txt; uuencode attach.out example1.txt) | \
    mailx -s "mail example 2 attachments" <user>@<domain.com> 
if (( $? != 0 ))
  then print "$0: uuencode or mailx failed"
       exit 3
fi
exit 0

You will get an e-mail with the same file attached twice.

Last edited by gary_w; 02-09-2012 at 05:35 PM..
# 4  
Old 02-09-2012
Quote:
Originally Posted by jgt
You are making the entire body of the email, the attachment. If you edit the received email and input the body to uudecode, you will get your original text.
Search "email attachment" in this forum, there are lots of examples.
Thanks i figured it out...


Code:
uuencode test.txt test.txt |mailx -m -r touser@domain -s "attach testing" fromuser@domain

but now it messes up by text.txt file...the output has some squares and stuff like that.... any idea how to get rid of that ??

Last edited by methyl; 02-10-2012 at 11:17 AM.. Reason: code tags
# 5  
Old 02-09-2012
How about you try the code he posted and see if that works instead?
# 6  
Old 02-10-2012
Quote:
Originally Posted by Corona688
How about you try the code he posted and see if that works instead?
I tired that but dose not work on HP-UX
# 7  
Old 02-10-2012
In what way does it "dose not work"? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cronjob output to file AND to email (as attachment)

I have a shell script that runs on our webserver logs, and grabs various useful data and then outputs this data to a .csv file. What I want to do now is schedule a cronjob to run this script for me each week at a designated time, AND email the .csv file that is created as an attachment to... (1 Reply)
Discussion started by: xdawg
1 Replies

2. Shell Programming and Scripting

Email with .dat file as attachment

Hi, I am trying to email a .dat file as an attachment from unix MS-outlook. I tried uuencode but it is not attaching the file, rather it is placing some junk data in the body of mail. Below is my code (cat Message.txt; uuencode Attach_File.DAT Attch_File.DAT) | mailx -s "SUBJECT"... (12 Replies)
Discussion started by: sampoorna
12 Replies

3. Shell Programming and Scripting

Replace A File From Email Attachment

I am looking for a method that would allow me to replace an existing file with one from an email attachment. Any way of scripting this, so when an email comes in from a particular email id, it takes the attached file, and replaces an existing file. (6 Replies)
Discussion started by: evencustard
6 Replies

4. Linux

Replace A File From Email Attachment

I am looking for a method that would allow me to replace an existing file with one from an email attachment. Any way of scripting this, so when an email comes in from a particular email id, it takes the attached file, and replaces an existing file. (4 Replies)
Discussion started by: evencustard
4 Replies

5. Shell Programming and Scripting

Sending a file as an attachment to email

The file is located under appl/batchdata/ file name: storesales.txt I am using following code because uuencode is not present. I am not getting the data in file but i am getting the blank file with same name as an email attachment. ( echo "from: sch@xxxx.com" echo "to:sch@xxxx.com" echo... (2 Replies)
Discussion started by: skatpally
2 Replies

6. Shell Programming and Scripting

Send a file through email using cron as an attachment

Hi All, I want to send a file as an attachment through cron job.Is this possible using cronjob nd if it i, can you please let me know how to do this? Thanks (2 Replies)
Discussion started by: NARESH1302
2 Replies

7. Shell Programming and Scripting

Sending email and attachment file using Perl

I am trying to send an email body of information and also attachment using perl script, but I am only able to send the body but not an attachment. is there around it without using "use MIME::Lite;" module. $user = "bataf\@xyz.com"; $subjectt = "mail from perl"; open(MAIL, "| mailx -s... (1 Reply)
Discussion started by: bataf
1 Replies

8. Shell Programming and Scripting

UNIX file attachment in email

Hi, I have a syntax for mail attachment as $EMAIL "Wrapper $wrapper_script_name has failed" " $wrapper_script_name has Failed " $failed_email_address and $EMAIL is as below MSGSub=${1} MSGText=${2} RMAIL=${3} #set LANG='' export LANG='' echo "${MSGSub}" | mailx -s "${MSGText}" ... (1 Reply)
Discussion started by: satgur
1 Replies

9. How do I send email?

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies

10. UNIX for Dummies Questions & Answers

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies
Login or Register to Ask a Question