One of the most requested features from my clients were: How can I easily send a link to a document?

Well, I think a pretty easy to use, fast and lovely way is to customize the hoverpanel / call out of the documents.

Normal document call out / hoverpanel:

Send link of document via mail (en)_1

 

The endresult we will get, looks like this:

Send link of document via mail (en)_2

And after you click on “Send link” you mailclient (in my case Outlook, german version) will open like this:

Send link of document via mail (en)_3

Now you can specify the send to property and the user will recieve a email like this:

Send link of document via mail (en)_4

In my opinion this is the perfect solution to send a link from a document.
So, how did I get this?

You can test it, if you place a Content-Editor webpart to your document library :

Send link of document via mail (en)_5

and place the following script into it:

<script>
SP.SOD.executeFunc("callout.js", "Callout", function () {
  var itemCtx = {};
  itemCtx.Templates = {};
  itemCtx.BaseViewID = 'Callout';
  // Define the list template type
  itemCtx.ListTemplateType = 101;
  itemCtx.Templates.Footer = function (itemCtx) {
    // context, custom action function, show the ECB menu (boolean)
    return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
  };
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
});

function AddCustomAction (renderCtx, calloutActionMenu) {      

  // Custom Action Send Mail
  var editPropUrl = renderCtx.CurrentItem.FileRef;
  editPropUrl = editPropUrl.replace(/ /g, '%20');

  var preUrl = _spPageContextInfo.siteAbsoluteUrl;

  calloutActionMenu.addAction (new CalloutAction ({
    text: "Send Link",
    tooltip: 'Send link to document',
    onClickCallback: function() 
    {  

       var strTest = buildMailTo('', 'Link to document', 'There you go: nn' + preUrl + editPropUrl + 'nn Cheers');
       window.location(strTest);

    }
  }));
}

function buildMailTo(address, subject, body, preUrl, editPropUrl) {
    var strMail = 'mailto:' + encodeURIComponent(address)
                   + '?subject=' + encodeURIComponent(subject)
                   + '&body=' + encodeURIComponent(body);
    return strMail;
}

</script>

Send link of document via mail (en)_6

After that everything should work. If nothing has changed check under Site settings -> Manage Site features -> Following Content & Minimal Download Strategy might be active. Try again with deactivated features.

If you want get this features in all your libraries you could append the script e.G. into your masterpage.

If you have questions, don’t be afraIT to ask or comment and if you like this blogpost, please share it in your social networks or follow me on twitter or facebook.

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here