From E-Mail


Last week, I had a client ask me how to implement sharing from an email. On the face of it, sharing isn’t that hard for any specific service.  Facebook has their way.  Twitter has its way.  But we’ve been using the service.  Wouldn’t it be nice if you could provide a way to implement sharing from within an email for any service provided?  And what if you could also add the “Share” button so that even if you didn’t put the service in the email that they wanted to use, they still were able to share using the share button?

Well, it took a while, but I finally figured it all out.

Since we can’t rely on JavaScript to get executed in the email client, we need to provide hyperlinks to a web page.  The web page will then automatically click the appropriate link to share.

On this page, you’ll put code similar to what provides for your site.  We will be using jQuery to fire the sharing code, so you’ll need to load that too.

In the head section of the HTML in your ASPX file, you can put in:

<script type="text/javascript"
  src="" ></script>
<script type="text/javascript">
    var addthis_share = {
        url: '',
        title: 'My Example Title'
<script type="text/javascript"

One thing to notice is the async=1 in the URL of the addthis_widget.js URL.  This causes the script to get loaded asynchronously.  This helps us avoid timing issues.

You’ll include whatever AddThis button you want to fire:


<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_serviceName"></a>


where “serviceName” is the service you want to fire.

Finally, you’ll add jQuery code to fire the button.

$(function () {
    // click the button for things like twitter
    window.location = $(".addthis_button_serviceName")
    // mouse over share button
    addthis_open($(".addthis_button_compact")[0], '');
 // redirect URL for things like Facebook sharing     window.location = $(".addthis_button_serviceName")        .attr("href"); });

The first line initiates the AddThis javascript code.  Then each of the following lines is executed.  Since only one of them will ever do anything, we can just execute them in order.

This code is a rough idea of how to get this all working.  It isn’t production code so you will probably need to tweak it for your own purposes.

I would suggest making the URL, Title, PublisherID, and button you want to fire all parameters so that you can use From E-Mail for multiple  sites.

Related Post

  • Filtering the Internet NoiseFiltering the Internet Noise My friend Bill posted a link to “A Day In The Internet” that started a discussion about the signal to noise ratio on the Internet. I commented briefly, but realized that my comment was turning ...
  • Twitter Follower ObsessionsTwitter Follower Obsessions Do you want to increase your followers?  Or are you as sick as I am of the various products that will help you increase your follower count? I’ve been on Twitter now for several months and t...
  • Facebook App using DotNetNukeFacebook App using DotNetNuke Yeah, I know.  It has been a LONG  time since I posted anything.  I’ve been busy. One of my recent projects brought up something I think you may be interested in so I thought I’d post about ...
  • jQuery, JSON, and ASP.NETjQuery, JSON, and ASP.NET A few months ago, I demonstrated how to use ASP.NET's JSON capabilities.  Lately, I've been demonstrating how to use jQuery.  Both use a considerable amount of JavaScript so if there is some way w...
  • jQuery – Retrieving HTML FragmentsjQuery – Retrieving HTML Fragments A couple of weeks ago I mentioned that I had built a tooltip using jQuery.  We focused mostly on the positioning of the tooltip at the time because, historically, that's where most of the work has...
  • Khalid

    Thanks for your information. I really enjoyed the article.