Attach Document from SharePoint Document Library to a New Email Message in Outlook

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.

7 thoughts on “Attach Document from SharePoint Document Library to a New Email Message in Outlook

  1. Hi,
    I’ve try that on my Sharepoint Online, but when I click on “Email Document”..doest do nothing..
    Any ideas?
    Thank you,
    Vittorio

  2. To attach a Sharepoint library file to an Outlook message, right click/Copy link on the Sharepoint library document, then paste this link after having clicked “Attach file” in a new Outlook message, simple…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About davros85

SharePoint / Azure Architect & Developer - Creator of ProvisionPoint, a site provisioning and change management solution for SharePoint Online