Try our conversational search powered by Generative AI!

Stian Grepstad
Sep 14, 2010
(4 votes)

How to post to Twitter and Facebook from edit mode in EPiServer – SocialPing.

SocialPing is a project that enable posting directly from EPiServer to ALL your social networks like Twitter, Facebook and LinkedIn in one go.

I have experienced that more and more customers is asking for ways to integrate their social media networks to their CMS solutions. After some research I found a lot of blog entries on how to build your own Twitter Workflow, how to build a gadget for reading updates from Facebook and Twitter but I couldn't find a way to publish to ALL my social networks. This was my motivation when I started working on a project that allows you to publish messages to all your social networks directly from EPiServer. The list currently contains 36 different networks – including Twitter, Facebook and LinkedIn.

SocialPing (which is included as a reference in your EPiServer project) uses services from to update your status on your social media networks. provides several ways to update your status. This project uses the email service to do the update.


You can download the source code for the project here:

SocialPing page on EPiCode.



1. Create your account on

After signing up, you have to assign the different social networks you want to hook your account to. The list contains 36 different social networks to choose from (Twitter, Facebook, LinkedIn, MySpace etc).


2. Grab your private email address

After assigning different networks you have to grab your private email address. This email address is found under “Services/Tools” on the dashboard. You are going to use this email address in step 5 in this tutorial.


3. Add a new property in admin mode

Now we have to define what to publish to the social networks when publish pages. We create a new property “PublishSocialMediaString” (string) to page type “News item”. Add this property to all page types you want to publish to your networks. I recommend to create a new tab for this property – just to separate this from the page content.



4. Copy folder “SocialPing” to the root of your EPiServer project

The folder contains two files: “settings.config” and “log.txt”.

The project is available for download here.


 5. Modify “settings.config”

Modify mail server settings and property name you created in step 3.


Attribute Description

Mail server. Example: “”


Mail server port. Example: “25”


Mail server username.

Example: “”


Mail server password


Recipient email address. Insert you private email address here (step 2). Example: “”


Your email address. Usually the same as “”


Name of the property created in step 3. The value of this property is the status posted to networks.

“PublishSocialMediaString” is used in this example.


True or false. Writes exceptions to log.txt if set to true.


Config.settings should look like this:

<?xml version="1.0" encoding="utf-8" ?>
    logexceptions="true" />


 6. Change Web.config (optional)

Change delivery method for SMTP to network and not IIS:

     <smtp deliveryMethod="Network" />



7. Add reference to “SocialPing.dll” in your EPiServer project.


8. Modify Global file in your EPiServer project

Now we have to attach a new PageEventHandler in Global.asax.cs. In this example we call method PostMessage when a page is published:


using System.Web.Mail;
using SocialPing;
protected void Application_Start(Object sender, EventArgs e){
     DataFactory.Instance.PublishedPage += new PageEventHandler(Instance_PublishedPage);
static void Instance_PublishedPage(object sender, PageEventArgs e){
   StatusMessage statusMsg = new StatusMessage();

(The project is now using EPiServers initialization system to do this process auto-magically. No need to change global.asax)



We’re now able to publish directly from EPiServer. Just to demonstrate we create a new page (News item), set a value for “PublishSocialMediaString” and click “Save and Publish”.


And that’s it – your status is updated!

A short URL to your page is created and appended on the status message:











About is a free service which makes you update all your social networks in one go. offers a variety of ways to integrate and post to social networks. This article describes how to use to update status messages using’s mail service. SocialPing is a class library which includes methods for sending status messages to forwards the message to your social networks.


Known limitations and further enhances

- The project relies on and assumes that their services is up and running.

- Your status is updated every time you publish a page. So if you publish a page ten times, you will have ten status updates in your twitter account. This should be handled by the plug-in. Now you have to leave the text field blank if you don't want to publish. You should be able to check (with a status field) if the current page is already posted to

- No character limitations. It doesn’t check number of characters before sending to Ping. The status messages should be limited to 140 characters (Twitter) including URL. A character counter should be visible in edit mode.

- No status message is displayed. The editor don’t know if the message was sent and updated in social networks.

- Current version uses txt-file for logging. Log4net should be used for logging.

- Next version should include methods for retrieving your last status messages by using API calls to

- It should be possible to choose which network you want to post to. This version is posting to all networks registered with your account.

- It should be possible to turn on and off posting with config file.

- The plan is to create a epimodule for easier installation and setup.



Read more about the project and download the source code on epicode.



Runtime: EPiServer CMS 6, .NET 3.5

If you want to change and compile the source code: Visual Studio 2008 SP1.



Your feedback is appreciated for further development of the project.

Feel free to contact me: stian.grepstad /at/






Sep 14, 2010


Sep 21, 2010 10:33 AM

Cool stuff
/ Anders Hattestad

Jarle Friestad
Jarle Friestad Sep 21, 2010 10:33 AM

Good stuff Stian

I would how ever improve one thing. Instead of manually registering the published page event + send the StatusMessage in global.axax => Use EPiServers initialization system inside StatusPing.dll to do this process auto-magically. E.g

public class StatusPingModule : IInitializableModule
public void Initialize(InitializationEngine context)
DataFactory.Instance.PublishedPage += Instance_PublishedPage;

static void Instance_PublishedPage(object sender, PageEventArgs e)
StatusMessage statusMsg = new StatusMessage();

public void Preload(string[] parameters)

public void Uninitialize(InitializationEngine context)
DataFactory.Instance.PublishedPage -= Instance_PublishedPage;

Sep 21, 2010 10:33 AM

Great post Stian. Really looking forward to using this in a project.

Stian Grepstad
Stian Grepstad Sep 21, 2010 10:33 AM

Thanks for the feedback Jarle!
This is a great improvement to the project - it will make the setup even easier :)

I have now changed (and released) the source code so it now uses EPiServers initialization system inside StatusPing.dll.
No modifications to global.asax is necessary to make the plugin work now.

Lars Bodahl
Lars Bodahl Sep 21, 2010 10:33 AM

Good stuff :)

Please login to comment.
Latest blogs
Developer meetups in Stockholm & Helsinki

It's time for developer meetups! Next month we will be in Stockholm and Helsinki. Join us for getting the latest updates from Optimizely, be inspir...

Magnus Kjellander | Feb 23, 2024

Roll Your Own Security Headers

Proper security headers are a must for your Optimizely driven website. There are a variety of tools out there that will help with this, but when...

Ethan Schofer | Feb 21, 2024

Migrate Catalog content properties

A colleague asked me yesterday – how do we migrate properties of catalog content. There is, unfortunately, no official way to do it. There are...

Quan Mai | Feb 20, 2024 | Syndicated blog

Adjust log levels in Optimizely DXP

You may adjust the log levels for your site in Optimizely DXP yourself, but only for the Integration environment. Follow this step-by-step guide.

Tomas Hensrud Gulla | Feb 20, 2024 | Syndicated blog

Introducing Search & Navigation Dashboard for Resource Usage

We're excited to unveil the latest addition to the Search & Navigation suite: a dashboard designed to proactively monitor your resource usage. It's...

Edvin Dackelid Johansson | Feb 20, 2024

Introducing Jhoose Security Module V2.0

Version V2.0 of the Jhoose Security module has been released and is available via the Optimizely nuget feed. This update not only squashes several...

Andrew Markham | Feb 19, 2024 | Syndicated blog