Jump to content

Keeping Table Alignment when Pasting on Email


cosmic_sniper

Recommended Posts

How can I keep the alignment of the table when the data is pasted on an email?

 

The output of the table is intended to be copied and pasted on an email on an external sever (e.g. yahoo, gmail). The problem is whenever the output is pasted on the body of email, it is distorted. It loses rows and column separations.

 

I am thinking of two ways to solve this (I don't know if these are possible.)

 

  • Apply some formatting to the table so that it would maintain it's alignment.
  • Use a code to make the output show directly to the body of a third party email service.

 

If the second option is possible, then it would be very great since the whole table intended to be sent through email is a separate file that is displayed using include().

 

Is there a way to achieve such a thing?

 

I hope I explained my idea clearly.

 

Thanks in advance.

Link to comment
Share on other sites

  • 2 weeks later...

When writing HTML into an email in Yahoo, Gmail etc it is very important to make sure you have the widths and lengths written in the <TABLE> tag and <TD> tag.  Worse case scenario use a piece on inline css to format it. 

 

Example: (Without CSS)

 

<table cellspacing="0" cellpadding="0" width="500" align="center">

 

<tr>

 

<td width="250"><p>Cell 1</p></td>

 

<td width="250"><p>Cell 2</p></td>

 

</tr>

 

</table>

 

 

Example: (With inline css)

 

<table cellspacing="0" cellpadding="0" width="500" align="center">

 

<tr>

 

<td style="width:250px;"><p>Cell 1</p></td>

 

<td style="width:250px;"><p>Cell 2</p></td>

 

</tr>

 

</table>

 

 

Hope this helps.

 

Ian

Link to comment
Share on other sites

When writing HTML into an email in Yahoo, Gmail etc it is very important to make sure you have the widths and lengths written in the <TABLE> tag and <TD> tag.  Worse case scenario use a piece on inline css to format it.

 

Thanks for the response.

 

It's nice that you pointed that out but I think (I'm not sure though) that would be applicable only if I would encode the output directly on the email. What I'm looking for is some sort of code that would allow users to copy-paste the output as it is (with the alignment) or better yet, a code that would directly email the output. One option might be the use of mail() but if I got it right, using that, the body of the email could only contain up to 70 characters which is a great limitation on my part.

Link to comment
Share on other sites

Oh, I see!

 

You want to make a script to send a HTML document to an email.

 

Hmm in that case the best thing to do is use the PHPMail but have a preset .html page which is ready to send out.  That way you could send the headers to the PHP Mail form sending it out and do it this way.

 

In order to customise the email you would customise the html file.

 

Is this what your looking for?

 

Ian

Link to comment
Share on other sites

If they must copy and paste, I'd assume that copying and pasting a version of the table with the explicit inline css would be best. Did you try that?

 

All email clients are different, you won't be able to ensure it works 100%.

Link to comment
Share on other sites

If they must copy and paste, I'd assume that copying and pasting a version of the table with the explicit inline css would be best. Did you try that?

 

All email clients are different, you won't be able to ensure it works 100%.

 

I'm not so familiar with CSS but I'm formatting the table using attributes on every HTML tag.

 

Oh, I see!

 

You want to make a script to send a HTML document to an email.

 

Hmm in that case the best thing to do is use the PHPMail but have a preset .html page which is ready to send out.  That way you could send the headers to the PHP Mail form sending it out and do it this way.

 

In order to customise the email you would customise the html file.

 

Is this what your looking for?

 

You mean using include() as a body of mail()? Did I get it right?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.