Show/Hide content in a Gmail email body

18,145

Solution 1

The simple solution would just be an HTML (no javascript) email with a "table of contents" at the top showing the various languages. Clicking a language in the table of contents would jump to that language's anchor in the HTML (and thus, the correct language message body).

The hard way to do this would be to write a Gmail contextual gadget:

https://developers.google.com/google-apps/gmail/contextual_gadgets

Solution 2

Options that don't work:

  • JavaScript doesn't work in Gmail
  • Pseudo-selectors aren't supported, so you can't do anything like :active td { height:100px }
  • display:none and visibility:invisible aren't supported

Ideas that might work

  • Point the image to your server, and get the HTTP headers. With a combination of HTTP_ACCEPT_LANGUAGE and the IP address, you should be able to serve up the appropriate image.
  • In Gmail labs, there is an option to add apps by XML. You could write an app that lets you do more advanced stuff, and tell your users to install that.

Personally, I wouldn't worry about just displaying the content one after the other. Put an index of the languages at the top of the email, with anchor links to the relevant language.

Share:
18,145
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    Our organization is completely on Gmail (Google Apps), and we are trying to figure out a way to show/hide content in the body of the email and have the recipient decide whether to show the content or collapse it to hide it.

    The reason why we need to do this is because we send out generic emails in various languages, so we want the recipient to simply click on their language and have the email show the text in that language.

    Things we want to avoid:

    1. Sending multiple emails out in different language (and have to manage email recipients languages and multiple emails).
    2. Display the content for all the languages one after another in the body of the email and have the user scroll down to their language.

    One way I thought of doing this is by using Javascript to show/hide a div in the email that would hold the content for each language. For example, I would have an "English" hyperlink, a "Spanish" hyperlink, a "Chinese" hyperlink, etc and on click, the JS would show the div associated to the language that was clicked.

    However, I was not able to get Javascript to run in Gmail when I sent a HTML email from an email client (Thunderbird).

    The solution I'm looking for should ideally only require Gmail as some of the users do not have access to browse any other site outside of Gmail from their Chrome browser.