Construct and Send Multipart MIME Mail

Hi,

I have requirment in shell script to incorporate multipart email with both html and text.

Here am giving the text version.

From: any@email.com
To: your@email.com
Subject: Success Execution - $company - Apps PO File Report


Apps PO File Report 

Summary:
#APPS Purchase order FIle#
Filename: 			/user/files/apps-po/samplefile.txt
Folder: 			./apps-po/
Time started		2014/07/10 03:12:31
Time completed	       2014/07/10 03:12:32

Details:
 Records present on file:           	8
 Records Skipped:             		1
 Records considered for staging:    	7
 Records Rejected:            		2
 Records Discarded:           		0
 Records Loaded into Staging		5

Here am giving the html version

<body>
From: any@email.com<br/>
To: your@email.com<br/>
Subject: Success Execution - $company - Apps PO File Report <br/><br/>

Apps PO File Report 

<hr/>
<b>Summary:</b>
<br/>
#APPS Purchase order FIle# <br/>
Filename: 			/user/files/apps-po/samplefile.txt<br/>
Folder: 			./apps-po/<br/>
Time started		2014/07/10 03:12:31<br/>
Time completed	2014/07/10 03:12:32<br/>

<br/>
<b>Details:</b>
<br/>
 Records present on file:           8<br/>
 Records Skipped:             		1<br/>
 Records considered for staging:    7<br/>
 Records Rejected:            		2<br/>
 Records Discarded:           		0<br/>
 Records Loaded into Staging		5<br/>
<br/>
</body>

I developed the .ksh script and here am giving the script

to="any@email.com"
from="your@email.com"
boundary=$(uuidgen -t)
now=$(date +"%a, %d %b %Y %T %z")

cat > pomsg.txt <<EOF2
From: ${from}
To: ${to}
Date: ${now}
Subject: This is a test multipart message
MIME-Version: 1.0
Content-Type: multipart/alternative;boundary=${boundary}


This is a text message.     --> Here am going to incorporate text version

--${boundary}
Content-type: text/html;charset=utf-8


<!DOCTYPE html>
<body>
<pre>
Hello,
 
This is a html version.     --> here am going to incorporate html version

Regards...
</pre>
<body>

--${boundary}--
EOF2
sendmail -i -t < pomsg.txt
sc=$?
echo "sedmail rc=${rc}"
if [[ $sc -eq 0 ]]; then
	rm -i pomsg.txt
fi

it should send you the html email if your email browser accepts html. If not, you�ll see the text version. Could you please help me how to incorporate html and text version in the above .ksh script.

Pls. help me in advance

thanks

How about this:

to="any@email.com"
from="your@email.com"
boundary=$(uuidgen -t)
body_boundary=$(uuidgen -t)
now=$(date +"%a, %d %b %Y %T %z")

sendmail -t <<EOF2
From: ${from}
To: ${to}
Date: ${now}
Subject: This is a test multipart message
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="${boundary}"

--${boundary}
Content-Type: multipart/alternative; boundary="${body_boundary}"

--${body_boundary}
Content-type: text/plain; charset=ISO-8859-1

This is a text message.     --> Here am going to incorporate text version
--${body_boundary}
Content-type: text/html; charset=utf-8
Content-Disposition: inline

<!DOCTYPE html>
<body>
<pre>
Hello,
 
This is a html version.     --> here am going to incorporate html version

Regards...
</pre>
<body>
--${body_boundary}--
--${boundary}--
EOF2

sc=$?
echo "sedmail rc=${rc}"

bakunin