Format text in mail attachments


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Format text in mail attachments
# 1  
Old 09-11-2012
Format text in mail attachments

Hi Gurus,

I am working on a script that sends a text file attachment on mail from unix server to my widows outlook mail box.

When i see the text file in UNIX it is perfectly formatted but when i open the same file in the mail, it looks weird as the next line is added to the same line.

For example, in unix the file looks like,
Code:
ABC#DEF
GHI#JKL
MNO#PQR

But the mail attachment looks like
Code:
ABC#DEFGHI#JKLMNO#PQR

The command i used to send mail from UNIX is
Code:
(printf "%s\n%s\n" "`cat bodyofmail.txt`";unix2dos mytext.txt | uuencode mytext.txt mytext.txt) | mailx -s "subject" me@mail.com

Please help me out in fixing this.

Last edited by Franklin52; 09-11-2012 at 09:48 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 09-11-2012
I think all it needed was a little ux2dos (unix2dos) on your file before sending it to mailx (why not, using a pipe...)
# 3  
Old 09-11-2012
Sorry... didnt see you were using unix2dos... but not clear what you are doing...
Code:
cat file_to_send | ux2dos | mailx -s "ljkdfj"  mail@address

should be enough ( well it works for me anyway...)

Last edited by vbe; 09-11-2012 at 10:06 AM.. Reason: had backslash interferences(?)...
# 4  
Old 09-11-2012
Hi,

Thanks for the reply.

Your command worked but it sent the text file in the body of the message itself.

I need the text file to be send as an attachment in the mail.
# 5  
Old 09-11-2012
So your first idea is the good one except of unix2dos... Are sou sure of the syntax? I know there are variations, it goes to convert the given file - To STDOUT or outfile to convert on the fly the inputfile...
# 6  
Old 09-11-2012
What is you OS (version)? Have you tried configuring a .mailrc file?
# 7  
Old 09-11-2012
Hi,

I am getting the mail with attachment using the command that i used. But it is not formatted.

I have used unix2dos as i am sending mail from the Linux x86_64 box to my mail account. Also the mail sending option is already configured as i am getting mails from my other scripts.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Uuencode for mail attachments not working

Hi, I'm trying to send mail with attachments using uuencode, but it doesn't work. Command (also tried with mailx): uuencode testfile testfile | mail emailadress The email I get doesn't have an attachment, and has this in the message body: begin 664 testfile %=&5S=`H` ` end ... (4 Replies)
Discussion started by: Subbeh
4 Replies

2. Red Hat

How to send mail with multiple attachments?

We don't have uuencode installed in our machines..... Please tell me how to send mail with multiple attachments ??? URGENT !!!!! Please tell me using command line (or) scripts.......... please...... Thanks in Advance.... (1 Reply)
Discussion started by: vamshigvk475
1 Replies

3. Shell Programming and Scripting

Adding Attachments to mail

Hi, I need to send a mail with html code in body and an attachment along with the body and subject. The html code must display a table with data in it in the mail. I have tried the 'sendmail' command, but I am am able to display the table in the mail and unable to attach an attachment. ... (5 Replies)
Discussion started by: Durga Prasad NK
5 Replies

4. Shell Programming and Scripting

Reading Mail attachments using unix

:wall:hi all, please somebody can help me out in reading the pop3 mail attachments or saving it locally i have a mail account where i receive .csv attachments i need to read that attachments and process them. any sample code can be much appriciated Removed email :wall: (3 Replies)
Discussion started by: srikanthkadapal
3 Replies

5. UNIX for Advanced & Expert Users

Mail attachments getting corrupted...

Hi , Whenever I try to send mails with attachments to external email Id's the attachment is not encoded properly which appears along with body (text) of the mail. The attachement is always getting corrupted. Can anyone please suggest a solution. Regards, Sandipan (1 Reply)
Discussion started by: Sandipan
1 Replies

6. Solaris

mail with attachments

I want to send a mail with three attachments, but nothing happened. I tried it with mail and mailx. Are there special options for these commands or is it not possible to send mails under Solaris with attachments? Must there be special adjustments in the environment? Can anyone give an... (6 Replies)
Discussion started by: ninjadan
6 Replies

7. AIX

Send mail attachments and have a mail body

Hi, How can I send mail attachments from shell script (AIX) and have a mail body as well ? Thanks in advance. (1 Reply)
Discussion started by: shibajighosh
1 Replies

8. UNIX for Dummies Questions & Answers

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 <... (6 Replies)
Discussion started by: rajendragora
6 Replies

9. UNIX for Dummies Questions & Answers

file name got cut when using mail attachments

I am using the following command to send a zip file as an attachment to my internet email-id. uuencode ABC_DEFG_HIJ.zip ABC_DEFG_HIJ.zip | mail -s "attachment from shell" pal@yahoo.com Eventhough i have given the attached file as 'ABC_DEFG_HIJ.zip', when i receive the mail in my internet... (3 Replies)
Discussion started by: Pal
3 Replies

10. UNIX for Dummies Questions & Answers

mail attachments

I'm writing scripts on HP-UX. Is there a way to attach a file to a mail message. I don't want to imbed the data in the mail message. (1 Reply)
Discussion started by: Multithreaded
1 Replies
Login or Register to Ask a Question