...

View Full Version : How to send html and plain text simultaneously??



midnite
02-11-2012, 04:24 PM
Hi there guys;

My query is very simple, does anyone knows how to create and sent hmtl and plain text emails simultaneously?? I've try to google it and i found this page http://www.wilsonweb.com/wmt5/html-email-multi.htm but i did not understood how and where to implement the following:

------=_NextPart_000_002C_01BFABBF.4A7D6BA0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I know how to create html emails using tables i just don't know what i need to do to send the email as text too, for example creating an html email and sending the email to someone that has hotmail that person would probably be able to see it the way i wanted but what if that person decides to view the email in a blackberry?? Then it would be almost impossible unless i send the email with a plain text version along. But How??

Can anyone help?? Also i would like not to use any other programming language apart from html for this...so no php, ajax or c# please it would make easier for me to understand how it works..

Apostropartheid
02-11-2012, 05:10 PM
Hi there guys;

My query is very simple, does anyone knows how to create and sent hmtl and plain text emails simultaneously?? I've try to google it and i found this page http://www.wilsonweb.com/wmt5/html-email-multi.htm but i did not understood how and where to implement the following:

------=_NextPart_000_002C_01BFABBF.4A7D6BA0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I know how to create html emails using tables i just don't know what i need to do to send the email as text too, for example creating an html email and sending the email to someone that has hotmail that person would probably be able to see it the way i wanted but what if that person decides to view the email in a blackberry?? Then it would be almost impossible unless i send the email with a plain text version along. But How??

Can anyone help?? Also i would like not to use any other programming language apart from html for this...so no php, ajax or c# please it would make easier for me to understand how it works..

We need some context. Are you trying to send this from a specific client or from a web form?

midnite
02-11-2012, 07:56 PM
Hi there Apostropartheid;
thank you for your reply, and this is an example of what i have
<table class="main" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div style="background-color:#5C85FF;">
<p style="padding:0.5em;">
<img src="#" alt="" name="Logo" width="220" height="25"/>
</p>
</div>
</td>
</tr>
</table>
<table>
<tbody>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="margin:1.5em 0 1em 0;">Asset Approval Request:</p>
</td>
</tr>
<tr>
A<td>
<p style="margin-bottom:0.6em;">Please be advised there is a file for approval.</p>
<p style="margin-bottom:0.6em;">Lorem ipsum</p>
</td>
</tr>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="margin:1.5em 0 1em 0;">Action(s) required:</p>
</td>
</tr>
<tr>
<td>
<p style="margin-bottom:0.6em;">Please <a href="#"> click here</a> to view and approve the below job.</p>
</td>
</tr>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="color:#000; margin:1.5em 0 1.5em 0; padding:0.2em;">Job Information:</p>
</td>
</tr>
<tr>
<td style="width=175;">Project Number:</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Job Number:</td>
<td><a href="#">Lorem ipsum</a></td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="color:#000; margin:1.5em 0 1.5em 0; padding:0.2em;">Approval Required By:</font></p>
</td>
</tr>
<tr>
<td style="width=175;">Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
</tbody>
</table>

<hr style="margin:1.5em 0 1.5em 0;" />

<table class="main" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<p style="margin-bottom:0.6em;">Please <a href="#">click here</a> to view and approve the above job.</p>
<p style="margin-bottom:0.6em;">If you require any further assistance please contact <a href="#">us</a>.</p>
<p style="margin-bottom:0.6em;">Kind regards,</p>
<p style="margin-bottom:0.6em;">Lorem ipsum</p>
</td>
</tr>
</tbody>
</table> and it will be mainly sent through hotmail or windows live mail to all outlook versions and some mobile phones such as blackberry not to mention that it will be viewed in most browsers as well.

I think this is what you looking for.

midnite
02-11-2012, 07:58 PM
As you can see if i send this to anyone that is unable to receive html emails i do not have a plain text version, and that is my question having this type of code how can i implement the plain text along with the html version if i make myself clear.

felgall
02-11-2012, 08:46 PM
You use Content-Type: multipart/alternative; to define that the email contains alternative parts - ie. text and HTML.

You then define a boundary that goes before , between, and after the parts. Each boundary starts with -- followed by the same randomly chosen value to allow the boundaries to be matched (so as to allow for attachments and related multiparts to use a different boundary). The last boundary also ends with --

In the first part you define Content-type: text/plain; and in the second part Content-type: text/html; along with the other headers needed top properly define each part (such as the charset to use).

As a cut down example just to show you what these might look like:


Content-Type: multipart/alternative;
boundary="=_6b90dbbfbc05492523784d50f6398c3f"


--=_6b90dbbfbc05492523784d50f6398c3f
Content-type: text/plain;
charset="iso-8859-1"

text version goes here

--=_6b90dbbfbc05492523784d50f6398c3f
Content-type: text/html;
charset="iso-8859-1"

html version goes here

--=_6b90dbbfbc05492523784d50f6398c3f--

In PHP I use '=_'.md5(uniqid(time())) to create boundary values.

midnite
02-12-2012, 12:06 AM
Hi there Felgall thanks for your help but still there must be something that im doing wrong, here is what i did:


Content-Type: multipart/alternative;
boundary="=_6b90dbbfbc05492523784d50f6398c3f"


--=_6b90dbbfbc05492523784d50f6398c3f
Content-type: text/plain;
charset="iso-8859-1"

text version goes here

--=_6b90dbbfbc05492523784d50f6398c3f
Content-type: text/html;
charset="iso-8859-1"

<table class="main" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div style="background-color:#5C85FF;">
<p style="padding:0.5em;">
<img src="#" alt="" name="Logo" width="220" height="25"/>
</p>
</div>
</td>
</tr>
</table>
<table>
<tbody>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="margin:1.5em 0 1em 0;">Asset Approval Request:</p>
</td>
</tr>
<tr>
A<td>
<p style="margin-bottom:0.6em;">Please be advised there is a file for approval.</p>
<p style="margin-bottom:0.6em;">Lorem ipsum</p>
</td>
</tr>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="margin:1.5em 0 1em 0;">Action(s) required:</p>
</td>
</tr>
<tr>
<td>
<p style="margin-bottom:0.6em;">Please <a href="#"> click here</a> to view and approve the below job.</p>
</td>
</tr>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="color:#000; margin:1.5em 0 1.5em 0; padding:0.2em;">Job Information:</p>
</td>
</tr>
<tr>
<td style="width=175;">Project Number:</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Job Number:</td>
<td><a href="#">Lorem ipsum</a></td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td style="font-size:18px; font-weight:bold;">
<p style="color:#000; margin:1.5em 0 1.5em 0; padding:0.2em;">Approval Required By:</font></p>
</td>
</tr>
<tr>
<td style="width=175;">Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>Lorem ipsum</td>
</tr>
</tbody>
</table>

<hr style="margin:1.5em 0 1.5em 0;" />

<table class="main" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<p style="margin-bottom:0.6em;">Please <a href="#">click here</a> to view and approve the above job.</p>
<p style="margin-bottom:0.6em;">If you require any further assistance please contact <a href="#">us</a>.</p>
<p style="margin-bottom:0.6em;">Kind regards,</p>
<p style="margin-bottom:0.6em;">Lorem ipsum</p>
</td>
</tr>
</tbody>
</table>

--=_6b90dbbfbc05492523784d50f6398c3f--



Then i've sent the email to myself and i could see the
Content-Type: multipart/alternative;
boundary="=_6b90dbbfbc05492523784d50f6398c3f"....and so on, also i've checked on my mobile phone which is a nokia the email and selected the option display plain text only and not only i could still see the Content-Type: multipart/alternative;
boundary="=_6b90dbbfbc05492523784d50f6398c3f" but also the entire html code as text ??!!!


Am i missing something??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum