Home » none » AddThis.com From E-Mail

AddThis.com 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 AddThis.com service.  Wouldn’t it be nice if you could provide a way to implement sharing from within an email for any service AddThis.com 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 AddThis.com 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="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" ></script>
<script type="text/javascript">
    var addthis_share = {
        url: 'http://www.example.com',
        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 AddThis.com 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 […]
  • 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 […]
  • 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 […]
  • 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 […]
  • jQuery UI – Resizable w/ ASP.NET ThemesjQuery UI – Resizable w/ ASP.NET Themes If you've been up to the jQuery web site and looked at the documentation for resizable() you probably thought, "hey, no problem, I can do that."  Well, that's what I thought, too, until I […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS.Does your team need additional help in any of the above? Contact Dave today.

  • http://abhworld.com Khalid

    Thanks for your information. I really enjoyed the article.