ShareThis: the subject shows up in the To field of an email client for the email share button

610 Views Asked by At

I am supporting a website that uses ShareThis. I notice that the email share is not configured properly. If one clicks on the email button, the following

&subject=I'd like to share a link with you

shows up in the "To" field of the mail client such as desktop Outlook. How can to fix this? The following is the ShareThis code the site uses:

window.__sharethis__.load('inline-share-buttons', {
    alignment: 'right',
    id: 'share-buttons',
    enabled: true,
    font_size: 12,
    padding: 3,
    radius: 2,
    networks: ['facebook', 'twitter', 'reddit',   'email', 'sharethis'],  
    size: 18,
    show_mobile_buttons: true,
    spacing: 4
});
1

There are 1 best solutions below

0
Preston S On

There isn't a built-in way with the ShareThis API to correct this issue but you can work around it by handling the share this onLoad event and intercepting the email button click event. I'm using jQuery but it's easy enough to accomplish the same thing with vanilla JS.

window.__sharethis__.load('inline-share-buttons', {
  alignment: 'right',
  id: 'share-buttons',
  enabled: true,
  font_size: 12,
  padding: 3,
  radius: 2,
  networks: ['facebook', 'twitter', 'reddit',   'email', 'sharethis'],  
  size: 18,
  show_mobile_buttons: true,
  spacing: 4,
  onLoad: function () {
    //override the default email sharing functionality since it's broken in outlook
    $('.st-btn[data-network=email]').on('click', function (e) {
      var subject = "I'd like to share a link with you";
      var body = $('#share-buttons').data('url');
      document.location = "mailto:?subject=" + subject + "&body=" + body;

      //Prevent default share this functionality
      e.stopPropagation();
    });
  }
});