Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to send html and plain text simultaneously??

    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..

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Quote Originally Posted by midnite View Post
    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?

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Arrow

    Hi there Apostropartheid;
    thank you for your reply, and this is an example of what i have
    Code:
    <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.

  • #4
    New Coder
    Join Date
    Jun 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,460
    Thanks
    0
    Thanked 632 Times in 622 Posts
    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:

    Code:
    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.
    Last edited by felgall; 02-11-2012 at 08:49 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    New Coder
    Join Date
    Jun 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi there Felgall thanks for your help but still there must be something that im doing wrong, here is what i did:

    Code:
    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
    Code:
    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??


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •