Script to Convert HTML to MIME mail -- HELP!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to Convert HTML to MIME mail -- HELP!
# 8  
Old 04-28-2009
Script to Convert HTML to MIME-SOLVED!!!

the error was very stupid!!!

the string in boundary is defined at start of mime BUT when is used MUST be preceded by "--" !!!!!

The script then is this:

Quote:
#! /bin/bash
SB=$1
IF=$2
OF=$3
rm -f $OF.b64

BND="==$(date +%N)$(date +%N)"

# CUERPO DEL MENSAJE
echo -ne "Subject: $SB\n">$OF.tmp
# echo "Date: $(date)">>$OF.tmp
# echo "MIME-Version: 1.0">>$OF.tmp
echo "Content-Type: multipart/related;">>$OF.tmp
echo -ne " boundary=\"$BND\"\n\n">>$OF.tmp
echo "This is a multi-part message in MIME format.">>$OF.tmp
echo "--$BND">>$OF.tmp
echo "Content-Type: text/html; charset=ISO-8859-1">>$OF.tmp
echo -ne "Content-Transfer-Encoding: 7bit\n\n">>$OF.tmp
#echo -ne "Content-Disposition: inline\n\n">>$OF.tmp
cat $IF>>$OF.tmp
echo -ne "\n\n--$BND">>$OF.tmp

# MIME DE LOS ARCHIVOS
for n in $(cat $OF.tmp|tr -d '"'|awk '/<IMG SRC=/{A=substr($0,index($0,"SRC="));printf ("%s ",substr(substr(A,1,index(A," ")),5))}');do
ID="part1.$(date +%N).$(date +%N)@linux.org"
MITY=$(cat mime.types|awk -v MT="$(echo $n|awk '{for(i=length($0);i>=1;i--) if (substr($0,i,1)==".") {print substr ($0,i);break}}')" '{if (MT == $1) {printf("%s\n",$2);exit}}')
echo -ne "Convirtiendo: $n -> $ID\n"
echo -ne "\nContent-Type: $MITY;\n name=\"$n\"\nContent-Transfer-Encoding: base64\n">>$OF.b64
echo -ne "Content-ID: <$ID>\nContent-Disposition: inline;\n">>$OF.b64
echo -ne " filename=\"$n\"\n\n">>$OF.b64
base64 $n>>$OF.b64
echo -ne "--$BND">>$OF.b64
cat $OF.tmp|sed "s/$n/cid:$ID/g">$OF.tmp
done
echo "--">>$OF.b64
cat $OF.tmp $OF.b64>$OF
Txs to all!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to convert my /bin/sh script with cgi and html to run it on browser!??

Hello, I want to run this script on my CentOS 6 via browser : ________________________________________________________________________________________________ #!/bin/sh echo Username? read MY_NAME echo Provisional file name? read MY_FILE echo File NAME you want to save? read MY_FILE2... (16 Replies)
Discussion started by: juta2020
16 Replies

2. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

3. Shell Programming and Scripting

Script to convert csv file to html with good visibility

Hi, I have Below script which converts csv file to html succesfully.but the visiblity is simple in black n white. I want to have better visibilty of each columns in different colours(like green).As it is a Database report suppose some tablespace available space is less than 20% then it should... (7 Replies)
Discussion started by: sv0081493
7 Replies

4. Shell Programming and Scripting

Script to convert CSV file to HTML

Hi, I have made a a script which creates a csv file as daily database report However i want to covert that csv file to html because csv file does not have a good visibilty. So it is possible to have such csv to html coversion script. Your prompt help much appreciated. Thanks in advance (4 Replies)
Discussion started by: sv0081493
4 Replies

5. Shell Programming and Scripting

Need to convert datafeed to html using script

Hi All, I am having datafeed content in CSV format like below. Any help to create a script. I need read the CSV file on loop and update it in html format for web publishing I want to chage the data using my token based template and save the file out to new csv file (3 Replies)
Discussion started by: ranjancom2000
3 Replies

6. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

7. Shell Programming and Scripting

MIME - HTML mail with Excel attachment - Please help!

#!/bin/ksh ( echo "MIME-Version: 1.0" echo "Content-Type: multipart/mixed; boundary=frontier" echo "--frontier" echo "Content-Type: text/html" echo "Content-Disposition: inline" echo "\n" echo "<html><body><h1>this is html formatted text</h1></body></html>" echo "--frontier" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

8. Shell Programming and Scripting

Awk script to convert csv to html

Hi Written some script to convert csv to html but could not add table headers.Below are the errors iam getting ./csv2html | more + awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
Discussion started by: zeebala1981
2 Replies

9. Shell Programming and Scripting

how to send mail in UNIX using MIME

Hi, I am searching for an option to send mail with multiple attachments using unix. I know uuencode option, but I dont have the executable in our machines. So I am looking for some other option to do this. And I heard that we can send mails using MIME. Can anyone help me with the syntax and... (2 Replies)
Discussion started by: srilaxmi
2 Replies

10. UNIX for Dummies Questions & Answers

Using MIME to send html files

:confused: I am a programmer, but need to work with UNIX in this particular situation. I am used to the plain "mail -s" command and also familiar with how to send attachments in html... but I now need to send an email (not an attachment) in html format so I can embed links... etc. I am told... (2 Replies)
Discussion started by: cgardiner
2 Replies
Login or Register to Ask a Question