69

I send a lot of HTML emails. The problem with GMail is, if there are more than one emails with the same subject, it hides some similar content and shows a "..." to show the "trimmed content". This screws up with my formatting.

If changing the subject is not an option, is there is any way to avoid this behaviour?

Edit: I should clarify that I programmatically send emails using Amazon SES from a php script. That is why I posted the question in Stack Overflow.

Munim
  • 6,310
  • 2
  • 35
  • 44
  • 2
    Is this a programming question? – Martin Smith Jun 18 '12 at 07:14
  • 4
    @MartinSmith I am talking about something I can do in my HTML, or in the email headers, or whatever hack I can do while sending the emails which will prevent this from happening, so yeah, it is a programming question. Sorry, I just realized that I didn't make this very clear when I wrote my question. – Munim Jun 18 '12 at 13:16
  • 5
    Emails do not control the behaviour of email clients. – Diodeus - James MacFarlane Jun 18 '12 at 13:20
  • 1
    @Diodeus yes, I get that. Theoretically, that may be the case. I was just wondering if there was some way to prevent this behavior in Gmail. Some change in markup which prevents it or something. – Munim Jun 19 '12 at 07:55
  • If you wrap your content in a big table with fixed dimensions, you do get some level of formatting protection. – Diodeus - James MacFarlane Jun 19 '12 at 13:32
  • I was facing similar problem in an automated email which I was sending using mailx. I ended up adding a random timestamp in subject of email which did the trick for me. – Ameliorator Apr 21 '13 at 08:00
  • @Munim, hi, how do i add timestamp to hard coded html email template, can use [this](http://stackoverflow.com/questions/10854874/input-type-datetime-value-format) html time tag or hidden [div](http://stackoverflow.com/questions/1992114/how-do-you-create-a-hidden-div-that-doesnt-create-a-line-break-or-horizontal-sp) with timestamp , can you show an example of what you did ? – Shaiju T May 14 '15 at 07:45
  • so stuipid a function is – Toma Jul 05 '22 at 15:26

12 Answers12

66

I've just encountered this problem myself, and from my investigations it seems that GMail does indeed trim the content if it is similar to the preceding emails.

My solution is simply to insert the current time stamp at the end of every email:

[15:02:21 29/01/2013] End of message.

dougwoodrow
  • 1,111
  • 12
  • 22
  • 3
    Thanks for the tip. An easy and slightly elegant way to ensure that emails don't trim. – Munim Jan 30 '13 at 06:03
  • Would this work as well if you had that in between comments tags in your html ? – thorne51 Jun 11 '15 at 10:36
  • 1
    before sending auto mail, In mail footer i `generated random alphanumeric strings in c#` check [this](http://stackoverflow.com/questions/1344221/how-can-i-generate-random-alphanumeric-strings-in-c?lq=1), hope helps someone. – Shaiju T Jun 27 '15 at 11:22
  • thats awesome tip doug – Shezi Apr 07 '16 at 05:01
  • Excellent. Then use CSS to set the text's opacity to 0. – ginna Aug 15 '16 at 21:19
  • 4
    This has now turned worse, as Gmail will quote blocks from the middle of an email as well, including headers, if the content is repeating. So I've resorted to inserting random characters before every `` closing tag, which seems to do the trick. – Adam Reis Dec 18 '16 at 08:31
  • This also uses it in the preheader text that looks awful. – Mike Flynn Apr 26 '22 at 14:07
33

To prevent this in HTML emails I'm adding two invisible unique elements: in the beginning and at the end of the mail. Like this:

...

<body>
<!-- this ensures Gmail doesn't trim the email -->
<span style="opacity: 0"> {{ randomness }} </span>

...

<!-- this ensures Gmail doesn't trim the email -->
<span style="opacity: 0"> {{ randomness }} </span>
</body>

{{ randomness }} is being replaced by my templating engine with the value of Date.now() (I'm using node.js, could be anything producing unique output)

Troggy
  • 915
  • 8
  • 18
  • 5
    This is the best answer, as of 2019. – Sõber Oct 28 '19 at 15:34
  • android chrome browser gmail opacity not working – Mustafa Apr 08 '22 at 00:38
  • but the datetime added in the first line of template will show up in the gmail email list instead of the actual content. by default, email list will show like subject-emailcontent now it will show like subject-date when u open gmail, yahoo etc.. – Sureshbabu T Oct 06 '22 at 13:18
  • @SureshbabuT you can insert the first randomness line a bit later in your content. Just make sure it is close to the beginning enough for Gmail not to trim. – Troggy Oct 07 '22 at 16:05
  • I have the feeling using transparent random text could trigger the spam filter. – lolesque Jan 10 '23 at 13:55
12

Voilà! Finally after long testing I have found a solution to this problem.

What Gmail does is it puts in the "Show Trimmed Content" option if the message is similar to previous ones, or the subject of the email appears as it is in the content of the email.

To avoid this, simply try inserting any randomly generated string inside your mail which will make your email messages different and will not let Gmail insert the Show Trimmed Content option.

Michael Myers
  • 188,989
  • 46
  • 291
  • 292
Sarthak
  • 121
  • 1
  • 2
  • Just to confirm in case not obvious, this seems to work if the string is hidden as well. ie within an html comment. So this won't compromise the layout of your email in any way at all. – AdamJones May 12 '22 at 12:50
5

If you cannot change your subject you can surely go for the optimization of HTML mailers.

  1. Because HTML file size allowed by Gmail is 102kb. If Gmail finds that your HTML file size is above 102kb then it will show message clipped at the bottom of your HTML mailer. File size is regardless of the image size which are included in the mailers(I am considering image link here).

  2. If there are many white spaces and carriage return in your HTML file. So best option is to inline your CSS using mail chimps inline CSS tool and then compressing your HTML file (Then are numerous HTML compressors available online). This 2 tricks should surely work in order to avoid your email has been clipped message.

For more reference can visit this link.

Ankita.P
  • 442
  • 1
  • 8
  • 17
5

Settings --> General --> Conversation View --> Conversation View off

This will basically not group the emails plus won't trim the contents.

Vicky
  • 431
  • 1
  • 6
  • 12
  • 1
    That's fine... but of course, this doesn't help a developer trying to make sure the emails you SEND don't do this. You can't ensure the end-user has this off. – Kenmore Jun 29 '18 at 21:49
  • This is the actual answer for viewing gmail emails with the trimmed content feature turned off – Will Sheppard Oct 02 '18 at 09:35
2

There are some workarounds in this thread:

http://productforums.google.com/forum/#!topic/gmail/yoAlDr3PyN4

Workarounds seem to be lame though. I hope you have a second name.....

I just remember that there was one recommendation, to use a different name in your signature.

If your name is Jim, try using Melvin, or Horatio. That should prevent the trimming, but it's not guaranteed.

Lernkurve
  • 20,203
  • 28
  • 86
  • 118
Victoria Ruiz
  • 4,913
  • 3
  • 23
  • 40
2

Inserting one or two random characters below your signature seems to confuse gmail enough to leave content untrimmed but also makes me look like a drunk crazy person. This issue needs to be resolved if google wants people to take gmail seriously. I would like the option to integrate more google products but flubs like this which should be no brainers make it difficult to commit.

sttdvs
  • 29
  • 1
2

In addition to the other answers, be aware that messages over 102K in size are likely to be trimmed. Watch out for bloated CSS or inlined images contributing to a file size that's too large.

Edit: Some sources of this information for the curious-

Zoot
  • 2,217
  • 4
  • 29
  • 47
  • That's interesting. It will be helpful if you have any source for this though. – Munim Jan 28 '14 at 04:55
  • 1
    Ah.. You are talking about the "message clipped" notice. Not exactly the same as my question, but relevant anyway. Thanks. – Munim Jan 29 '14 at 04:59
2

I think this would be best option to avoid the "Hide expanded content Gmail" and prevent the content be stripped.

There are two ways to do it.

  1. Just add a random number at the end of your email
  2. Just adding bookmarklet to your bookmark toolbar and just click when you are going to compose an email

For more details please follow the below link

Refference

dush88c
  • 1,918
  • 1
  • 27
  • 34
2

Gmail does this if the mail content is the same if the receiver has the same content from the same address. Therefore you should be generating some random ID, or make changes inside your HTML dynamically. Also, if you put random ID inside your content with hidden type will be ignored hidden type.

Solution: while generating HTML with python, I have decided to put today's date.

import datetime
datetime.datetime.now().strftime("%d %B %Y, %H:%M:%S %p")

13 August 2020, 20:29:15 PM
Sabuhi Shukurov
  • 1,616
  • 16
  • 17
1

Just insert any unique content after the trimmed contents. That can be anything. Even you can make it invisible by adding it in very light color, like light gray.

Joel James
  • 1,315
  • 1
  • 20
  • 37
-5

Just delete the little bars right above your gmail signature that separate your message from the signature.

joseph
  • 9