Feeds:
Posts
Comments

I’m afraid I can’t take the credit for this one – my colleague Jagan came up with this neat solution to allow a user to attach a document from  a SharePoint document library straight to a new Outlook email message. Don’t ask me why MS don’t include this OOB – I get asked about it so often…

The Problem

The problem with using a document library to store documents is that it can be tricky to get a document out and email it outside of the organisation. It’s not always practical to setup extranet sites etc etc – sometimes you just need to email a document out.

Usually, you’d have to download the document from the library to your desktop, then start a new email, then attach the document.

[A] Solution

This solution is not *perfect*, and it will not work in all scenarios – but it will work in most.

You just need to create a feature with a CustomAction block, shown below:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="AttachToEmail.ItemToolbar"
                RegistrationId="101"
                RegistrationType="List"
                Location="EditControlBlock"
                Sequence="900"
                Title="Email Document" 
                ImageUrl="/_layouts/images/EmailPST.png">
    <UrlAction Url="javascript:function launchOutlook(itemUrl){
                var docUrl = location.protocol + '//' + location.host + itemUrl;
                var objO = new ActiveXObject('Outlook.Application');
                var objNS = objO.GetNameSpace('MAPI');
                var mItm = objO.CreateItem(0);
                mItm.Display();
                mItm.Attachments.Add(docUrl);  
                mItm.GetInspector.WindowState = 2;
                }launchOutlook('{ItemUrl}');"/>
  </CustomAction>
</Elements>

 

When you activate the feature, you should see an extra menu option in

your Edit Control Block (ECB) dropdown on each document in your library:

image

This will use the Outlook ActiveX control to stream the document to a new

email message:

image

Some Caveats

As I said – there may be some limitations with this approach:

1. Only one document can be added to each email (in this version – it would be possible to modify the above to cater for a selection of documents)

2. Since it’s ActiveX – cross browser support is v.sketchy – IE only really

3. It’ll work best in standard internal ‘intranet’ environments, where the authentication is integrated

 

… but, that’s it. Give it a go in your projects and let me know how it turns out.

 

If you’d like me to wrap it into a WSP for download leave a comment…

.davros.

A little while back I had to create a solution to colour code a 2010 calendar to be used for internal scheduling here at bluesource… so I thought I’d share it with you chaps..!

The idea behind it is that a list can be used to manage unique keys against colour values. For instance, say a single calendar is used to book all projects. Each project has a unique number, and you wanted those to be automatically colour-coded (without having to use calendar overlays). This solution allows you to specify a key against a colour value – eg ‘Whichever calendar entry has [1234AABB] in the title of the entry, I want to be blue (#000066)’ .

 

Download the WSP Here: bluesource.intranet.zip

Please Note: bluesource does not accept any liability for this solution, it is the work of myself only – and as any custom solution, should be installed on development systems first.

It comprises of 2 pieces:

  • A list definition – A list will need to be created from the definition. Unique keys and colour values are entered into the list (in the same site collection as the calendar).
  • A web part – which will need to be added to the calendar page (this injects some javascript goo to do the colour coding). This needs to be pointed at the list (in the web part settings).

 

Installation

  • Deploy the WSP, and activate the Bluesource.Intranet.CalendarColours feature in Site Collection Features.

image

  • Create a new list from the ‘CalendarColours’ list definition.
  • Enter your values in the list (shown below):
    • Title: The unique key to look for the calendar title
    • Background Hex Value: Hex colour value to make item background
    • Text Hex Value: Hex colour value for text

image

 

  • Add the Calendar Colour Coding web part to the calendar page:

image

 

  • Enter your calendar entries, using the unique keys – and voila:

image

 

Hope this helps – if people want the source code leave me a comment…

 

.davros.

So I recently had to write a console application to post data to a SharePoint 2010 list, using the web services – but without using any ‘normal’ .NET web references. The server was set up with Basic Authentication.

This involved forming the SOAP envelope manually, and using a POST command. One thing that tripped me up (…and very nearly made me cry) was that most samples on the net use <soap:Envelope> – whereas it only worked for me when I used <soap12:Envelope> (with the correct namespace of course).

Anyway the code is below – so hopefully it might help some of you not waste so much time as I did… ;/

 

.davros.

 

static void Main(string[] args)
        {

            string soapEnv = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
                " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
                " xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
                "<soap12:Body>" +
                "<UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" +
                "<listName>TestList</listName>" +
                "<updates>" +
                "<Batch>" +
                  "<Method ID=\"1\" Cmd=\"New\">" +
                    "<Field Name=\"Title\">Added item</Field>" +
                  "</Method>" +
                "</Batch>" +
                "</updates>" +
                "</UpdateListItems>" + 
                "</soap12:Body>" + 
                "</soap12:Envelope>";

            string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username@domain + ":" + "password"));
            
            string uri = "http://sharepoint-url-here/_vti_bin/lists.asmx"; 
            WebClient client = new WebClient();
            client.Headers["SOAPAction"] = "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"; 
            client.Headers["Content-Type"] = "application/soap+xml; charset=utf-8";
            client.Headers["Authorization"] = "Basic " + user;
            client.Encoding = Encoding.UTF8;

            System.Text.ASCIIEncoding encode = new ASCIIEncoding();
            Byte[] bytes = encode.GetBytes(soapEnv);

            try 
            {
                string response = client.UploadString(new Uri(uri, UriKind.Absolute), "POST", soapEnv); 
            }
            catch (Exception ex) 
            { 
                Console.WriteLine("Doh!"); 
            }


        }

2010 in review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A helper monkey made this abstract painting, inspired by your stats.

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 2,600 times in 2010. That’s about 6 full 747s.

In 2010, there were 2 new posts, growing the total archive of this blog to 14 posts. There were 8 pictures uploaded, taking up a total of 1mb.

The busiest day of the year was March 2nd with 38 views. The most popular post that day was About Me.

Where did they come from?

The top referring sites in 2010 were baddaz.com, topsharepoint.com, spqteams, google.com, and linkedin.com.

Some visitors came searching, mostly for sharepoint makes me cry, javascript popup div, mail2sharepoint, infopath popup window, and javascript popup.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

About Me August 2009

2

InfoPath Popup Forms for Public Facing Websites (Web 2.0 Style) September 2009
2 comments

3

InfoPath Custom Save Action: Save as Draft and Avoid Validation July 2009
1 comment

4

InfoPath and Windows 7: System.Security.SecurityException September 2009
2 comments

5

InfoPath Rich Text Display in Form: Expression Box December 2008

We’ve just launched our latest MOSS website here:

http://www.GeorgeBurrows.com

Much of the site is standard MOSS functionality – apart from custom built top and left navigation web parts (shown below)…

 

Top Nav

To enhance the user experience in navigating the site, I developed a custom Top Navigation control (pictured below). The control cycles through each subsite and it’s Pages library, bringing back all the Pages which the user has declared to be on the navigation. Then the Title, Description and a custom ‘NavImage’ image field is displayed in the flyout. The Flyout is standard CSS and JS.

image

 

image 

 

Left Nav

The left navigation control was built to enable more accessible <UL> and <LI> elements to be output.

image

 

.davros.

I’ve been working on a WSS site for a friend of mine in my spare time lately, and it’s finally ready to launch!

Take a look if you’re interested: http://www.CambridgeAutogleam.com

image 

 

Main highlights of development…

1) Portfolio. Mapping a drive to the image library behind the scenes, he’s able to drag and drop a new folder in per car he details. So – content management requiring no SharePoint skills. In the front end – the latest 3 cars are shown on the homepage, and a customised CSS + JavaScript PopUp layer are used to show more photos of the car without navigating the user away from the page.

JQuery is used to highlight the selected image, and JavaScript swaps the images from the thumbnails to the main image – so no postback.

image  image

image

 

2) Banner Image. You’ll notice that the main image in the banner on each page is different. A standard image library contains a number of possible images, a data view is inserted in a DIV layer in the master page, and a JavaScript function runs to select one of the images randomly and display it.

 

3) Testimonials. Testimonials are driven from a list in the administration site. To add a new testimonial, he just has to add a new item to the list. Items are just ordered by date created, keeping things nice and simple. Data views are used to display them.

image  image

 

4) Twitter interaction. I initially used some of the standard twitter XML data to display updates in the footer of the site – but after deployment to 1and1 it seemed that these feeds were blocked. To work around the issue, I took the approach detailed here: http://blog.bullseyeconsulting.com/archive/2009/01/04/twitter-on-sharepoint.aspx , which meant the call to the twitter update runs from the client rather than server.

 

Hopefully this proves that interesting and dynamic websites can be built on a WSS platform! Let me know what you guys think…

 

.davros.

Follow

Get every new post delivered to your Inbox.