Share content by email, from a link

Here’s an up-to-date code that will allow you to share content from a website, by email.

Installing jQuery

Go to site settings > custom code > Head code and past the following :

<script src="" integrity="sha512-aVKKRRi/Q/YV+4mjoKBsE4x3H+BkegoM/em46NNlCqNTmUYADjBbeNefNxYV7giUp0VxICtqdrbqU7iVaeZNXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Save & publish

Adding required id’s

Add share-mail id to the element you want to click on

Adding the code into the page body

	$( document ).ready(function() {
		$("#share-mail").on("click", function(){
			location.href = 'mailto:[METTRE_TON_EMAIL]?subject=[METTRE_TON_SUJET]&body=[METTRE_TON_SLUG_ICI_AVEC_TON_TEXTE]';

The followin site is also useful to generate everything for the mailto.

It’s working perfectly ! Do you have a solution to be able to add an hyperlink to the email text please ?

@yann_nze Try the generator Vincent shared above.
It will encode links fine.

Hi Vincent or anybody else, is it possible to do this with a pdf that comes from a cms collection?

My client is asking for a way to share a pdf with colleagues via email (pdf: usermanual from a support page)

Fingers crossed for a fast reply - appreciate it a lot

Best regards
Louise Christensen

If you want to do this is a “crude” situation where the visitor is composing an email that contains a link to the PDF then you can do that by emitting the PDF link into the page, and then use it to create the mailto link body.

However the PDF will not physically be in the email as an attachment, you’ll see a long ugly URL, and the email will come from the site visitor.

If you are trying to email a PDF from your business to a visitor-supplied email address, as an attachment, you’d do this with a little bit of javascript and an automation to create the email + attachment. Make + Mailjet is a good option there but there are many options.

Drop me a message if you need help building this.

Hi Michael,
thank you so much for your fast reply on this - highly appreciated.

It does not matter that the pdf comes from the site visitor, as long as the receiver can download and see the pdf (which will be user manuals):slight_smile:

I tried Vincents code above on a button linking to a pdf from the cms, but it does not seem to work…Not sure if I did it correctly, just assumed that it was because it’s a cms-element?

I’m not really sure if I know exactly what to do now :slight_smile: Hope to hear from you again soon…thanks in advance for your reply on this, appreciate it a lot!