Sending a csv attachment and html text together.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending a csv attachment and html text together.
# 1  
Old 06-22-2012
Sending a csv attachment and html text together.

Hello,

I need to send below text (in a file ABC)as html text in mail body and the same as csv attachment
Code:
1,2,3
4,5,6
7,8,9

but to send as html text in mailbody we use
Code:
echo "Subject: Report " | cat - ABC | /usr/lib/sendmail -t a@xyz.com

and to send as an attachment in csv format we use
Code:
uuencode ABC ABC | mailx -s "subject" a@xyz.com

How we can club both to have single mail having html text and csv attachment as well?

Last edited by Franklin52; 06-25-2012 at 08:47 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 06-22-2012
Please post what Operating System and version you have and what Shell you use.
# 3  
Old 06-22-2012
SunOS 5.10 and ksh
# 4  
Old 06-22-2012
A common format with sendmail using MIME,

Code:
sendername="some name"
senderaddress="some address"
sendto="some address"
now=$(date)
version="1.0"
boundary=$$
filenmae=

tempfile=tmp.$$


echo "From: \""$sendername"\" <"$senderaddress">" >> $tempfile
echo "To: "$sendto >> $tempfile
echo "Date: "$now >> $tempfile
echo "Mime-Version: 1.0 "$version >> $tempfile
echo "Content-Type: Multipart/Mixed; boundary=Message-Boundary-"$boundary >> $tempfile
echo "Subject: "$subject>> $tempfile

echo "--Message-Boundary-"$boundary >> $tempfile
echo "Content-type: text/html; charset=US-ASCII" >> $tempfile
echo "" >> $tempfile
echo "" >> $tempfile

cat $filename >> $tempfile

echo "" >> $tempfile

echo "--Message-Boundary-"$boundary >> $tempfile
echo "Content-type: Application/Octet-stream; name=$filename; type=Binary" >> $tempfile
echo "Content-disposition: attachment; filename=$filename" >> $tempfile
echo "Content-transfer-encoding: X-UUencode" >> $tempfile
echo "" >> $tempfile
uuencode $filename $filename >> $tempfile



/usr/lib/sendmail $sendto < $tempfile


rm $tempfile

# 5  
Old 06-25-2012
Actually I need to send csv attachment and html text together in a single mail so that below data comes in tabular format in mail body and in csv as a attachment:

1,2,3
4,5,6
7,8,9

Please suggest. Let me know if anything is unclear.
# 6  
Old 06-25-2012
For CSV to HTML conversion see: https://www.unix.com/302302435-post5.html
To send HTML mail with attachment see: https://www.unix.com/302351004-post3.html
# 7  
Old 08-30-2012
Hello,

I'm having a mail with a .csv attachment. I need to extract this attachment & store it in a text file.

Any ideas are really appreciated.

Thanks.

Moderator's Comments:
Mod Comment Please start your own thread and do not hijack other threads

Last edited by methyl; 09-01-2012 at 10:10 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in sending html mail with attachment

Hi Everyone, I am facing problems in sending html mail with attachemnt. I will able to send mail with attachment (plain text ) using mailx -s and uuencode command and also html mail without attachment using sendmail option. However I am not able to send html mail along with attachment.Either... (2 Replies)
Discussion started by: karthik adiga
2 Replies

2. Shell Programming and Scripting

Mail sending with multiple attachement(pdf and csv) with html content from Linux

Hi, We have a requirement to send multiple attachment(pdf and csv) along with html content in a single mail. For that we are using uuencode. It is working for single pdf attachment and html content. But we are unable to send both pdf and csv attachment with html content. Below is the script.... (5 Replies)
Discussion started by: dholea
5 Replies

3. UNIX for Dummies Questions & Answers

Sending html email with html attachment

Hello, I have a script which is sending an html file as an attachment. #!/usr/bin/ksh export MAILTO="user@company.com" export CONTENT="/usr/tmp/file.html" export SUBJECT="EmailSubject" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (0 Replies)
Discussion started by: sreenathkg
0 Replies

4. Shell Programming and Scripting

Problem in sending inline html with an attachment using sendmail

MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=border --border Content-Type: text/html Content-Disposition: inline <html><body><h2>This text should be displayed with html formatting</h2></body></html> --border Content-Type: text/plain Content-Disposition: attachment This text... (2 Replies)
Discussion started by: thulasidharan2k
2 Replies

5. Shell Programming and Scripting

Not able to attach text in body of email while sending mail with attachment

Hi, We have been trying to send mail with attachment and it is going fine, but when we try to attach a text to the body of the email, we find that the mail is going fine with the body text but the attachment is not going through. We are using ksh. The command that is successfull without the... (6 Replies)
Discussion started by: jmathew99
6 Replies

6. Shell Programming and Scripting

Sending HTML attachment through mail

Hi I am new to unix and scripting.I am trying to send a html file as an attachment. SUBJECT="Type of Exceptions in Application" TO=Sushovan.Samals@gmail.com SPOOLFILE=/data/reg/tlogs/Monitor.html #echo "Send the E-mail message..." uuencode $SPOOLFILE $SPOOLFILE | mailx -s "$SUBJECT" $TO... (2 Replies)
Discussion started by: sushovan
2 Replies

7. UNIX for Dummies Questions & Answers

HTML message with attachment (text-file)

Hello: I've searched de forum but could not find an answer to send an email via sendmail in HTML with an text-file (plain-text) as attachment: My code: export FROM="Me" export MAILTO="mymail" export SUBJECT=$TITULO$bbdd export BODY=$LOG ( echo "FROM:$FROM" echo "To: $MAILTO"... (2 Replies)
Discussion started by: Felix2511
2 Replies

8. Shell Programming and Scripting

Send an attachment and html text both in the same mail

Hi all, I am working on UNIX (Solaris28). I would like to send an email in which the body will be in html format and, in the same mail, a xls file has to be attached. I have tried this: the file is correctly attached but the body comes as html source and not formatted. If I do not attach the... (4 Replies)
Discussion started by: stefan.yu
4 Replies

9. Shell Programming and Scripting

Sending email with text & attachment using mailx

I spent some time working this out, with a little help from various forums, and thought the community would like to know : Here is how you can send an email from a single Unix command line : /usr/bin/echo "Email text\nNew line\nAnother new line" >x | uuencode sourcefile.txt sourcefile.txt |... (3 Replies)
Discussion started by: haryadoon
3 Replies

10. UNIX for Advanced & Expert Users

sending mails with attachment and also some text in mail body

Hi, Can some one help me with the syntax of the mailx that should send an attachment and also some text in the message body together. When I am using the following syntax it is not sending the attachment but only the message body. unix2dos -ascii $REPORTFILE | uuencode $PCFILE | mailx -s... (7 Replies)
Discussion started by: guptan
7 Replies
Login or Register to Ask a Question