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="">
  <CustomAction Id="AttachToEmail.ItemToolbar"
                Title="Email Document" 
    <UrlAction Url="javascript:function launchOutlook(itemUrl){
                var docUrl = location.protocol + '//' + + itemUrl;
                var objO = new ActiveXObject('Outlook.Application');
                var objNS = objO.GetNameSpace('MAPI');
                var mItm = objO.CreateItem(0);
                mItm.GetInspector.WindowState = 2;


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:


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

email message:


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…


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

  1. I was able to import and activate it but when I click the “Email Document”, it does not do anything. Any ideas? Thanks!!

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

  3. 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: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

About davros85

Software Engineer @ Microsoft, working with key customers to help them be successful on Azure