Embedding table into an email
-
I have a WordPress page that I send out as an email newsletter. Everything looks fine, except the colors for the table are missing. Is there a way to embed the table from Tablepress into the email while maintaining the CSS?
-
Hi,
thanks for your question, and sorry for the trouble.
Unfortunately, I’m not aware of a solution for that, as I’m not an expert in HTML email management. ?? Sorry.
Regards,
TobiasHi no problem. Actually this is not about email but instead about CSS. A manual solution is to place the full CSS from tablepress into the email rather than have a link, since links are stripped. So that is what I will do ??
Hi,
that’s what I meant ?? I have no clue how to embed CSS in emails. ??
Good to hear that you found a solution!Best wishes,
TobiasHi WPChina and Tobias,
i want to send Embedding Excel table into an email. Have you a solution ?
I want to use a button and sending table at excel format to a fix email adress.
ScreenPictureThanks
Best regards
EricHi Eric,
no, sorry, I’m not aware of a solution to that.
Regards,
TobiasOk, I have a solution. However, you must understand the requirements and shortcomings of emails first:
1) Emails cannot have <form> inside. If they do, they will marked as phishing/spam by most recipients.
2) Emails can’t access json or javascript because they also will be marked as phishing and spam messages.
3) Email programs will often strip out the <head> of an email. That means if you embedded CSS int he <head>, it will disappear. A workaround for this is to *also* place the CSS within the <body> of the email.So that means when you embed your table into an HTML email, you can only expect to have the table contents available. You will not be able to have the search box, or other niceties like column adjustments.
To make the HTML email, I just add a file in my WP installation called email.php and I put it in a directory called /email/. So if my WP is installed at domain.com, the email is found at domain.com/email/email.php. I then add this to the top of the email.php:
<?php require('../wp-blog-header.php'); ?>
That one line of code will allow your email.php to act as if it is part of your WP installation.
Then I add the shortcode somewhere in the HTML body of the email.php like this:
<?php echo do_shortcode("[table id=15 hide_columns=all show_columns='A,B,G,K' /]"); ?>
Then it works. Just copy the HTML source of domain.com/email/email.php from your browser and paste it into your email program to send.
The downside is without the CSS, the table will just be text. So it will look bad. If you load the CSS in the <body?> it will look better, but I have an even better idea:
Maybe allow TablePress to operate without any “outside” effects like json/css/etc. Instead just print a table and have CSS as part of the div to make the columns different colors. One way to do that is to allow some more parameters in the shortcode such as:
a) external_files=off [this means the table relies on no external styles or code files]
b) header_color=#669999 [this allows the header of the column to have specific color]
c) footer_color=#669966 [this allows the footer of the column to have specific color]
d) row_color_alternate=’#000066,#006666′ [this allows us to manually set the 2 colors to make each row an alternating color. The first color in the list is the first color on the top row below the header, if the header is given its own color]
e) table_border=2 [pixels for the border size]
f) table_padding=5 [pixels for the padding size]However, I found a bug, and I’m not sure if it a security issue….
If you login as admin to your WP within the same browser as you load domain.com/email/email.php you will see an “Edit” below the table. I actually didn’t pay attention the first time I did this, and I sent that to a few thousand members of a WP site I manage. So they could click on the Edit link and visit the WP admin login page. They still needed a password to login, so it was relatively safe, but I’m unsure why the Edit link always shows and how to remove it. Any ideas?
-
This reply was modified 7 years, 5 months ago by
WPChina.
Hi,
thanks for sharing this! I hope it has some pointers for eric44 that will help!
Regarding the “Edit” link: This is visible to users who are logged-in and who are allowed to edit tables. Now, of course, if this is cached or copied to the email content, it will be visible there as well. (Nobody will be able to use it however, who is not allowed to edit tables!)
You can still hide it if you want, using https://tablepress.org/extensions/remove-edit-link/Regards,
TobiasThank you for the Edit link removal extension!
Also, please look at my suggested parameters. Any chance we can include those in the future? ??
Hi,
no problem! Good to hear that the Extension helps!
As for the other Shortcode parameters: This would be something that you could try adding in a custom Extension. I don’t think it’s very useful for the majority of plugin users, in my opinion. Sorry.
Regards,
TobiasHi WPChina and Tobias.
Thank you for your support.Sorry, but actualy when we using EXCEL Button : we saving table to an Excel (.xlsx) file to local user machine.
I just want a new button to save this Excel (.xlsx) file to a fix email adress or web server or other…
We want to offer the user the possibility of recording his result to a centralized place to make statistics of the choices of the different users.Is it possible ?
Thanks
Best regardsHi,
no, that will not work. All these buttens work on the client side only. For sending such emails, you would have to develop a custom server side script as well.
Regards,
TobiasI created an addon for this! I will send it to Tobias via email now.
Hi,
awesome! Thank you for sending it to me! I will take a look at it shortly and then consider adding this to the other Extensions!
Best wishes,
TobiasHi Tobias,
is it possible to test this addon to send an email ?Thanks WPChina for your addon, best regards.
Best wishes,
Eric -
This reply was modified 7 years, 5 months ago by
- The topic ‘Embedding table into an email’ is closed to new replies.