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:
The endresult we will get, looks like this:
And after you click on “Send link” you mailclient (in my case Outlook, german version) will open like this:
Now you can specify the send to property and the user will recieve a email like this:
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 :
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>
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.
3 responses to “Send link of document over hover panel via mail (en)”
Hi
An improved version of the script above has been added to the automated plain365 (free) installer: https://fiechter.eu/p365/
If you don’t want to play around with the java scripts, the installer is the perfect way to deploy the script. A reference to this website is also added.
Thank you very much for your script! It is a very elegant solution.
You’re welcome Peter. Glad I could help out! If you need anything, you can also get in touch with me via mail at patrick@afrait.com