Partager via


How to “not” connect SharePoint document library to Outlook Client

Recently while working with a customer, got a requirement which got me digging into the emails generated by SharePoint alerts.

When you setup alert in a SharePoint document library and get an alert email, you get an option to connect or subscribe to that particular Document Library from within Outlook.

image

Now customer wanted to have the alert emails sent, but did not wanted to have “Connect to this Document Library” connection button within the Outlook client.

As it is just like any other email and research done during a previous issue on SharePoint alert emails,  started by looking at the email headers being sent by SharePoint and started playing by removing them 1 by 1. This started crashing Outlook client whenever an email with modified header comes in.

Sometimes the email would come but I would not be able to open the alert email and just show a dialog “Cannot open this item”.

image

After playing around for quite sometime with different headers and crashing Outlook a number of times, found out that the Outlook connection to the SharePoint happens due to the Content-Class header. If Content-Class header exists and has got value of "sharing", then only Outlook with parse other "x-" headers and show you the "Connect to this Document Library" button in Outlook client.

image

If you delete the Content-Class header from the collection or set it to something else than "sharing", Outlook client safely assumes it to be a normal alert email and still show it as an Alert email but does not show you the “Connect to this Document library” button any more.

image

You can modify the headers of the alert emails by creating your own Alert notification handler by implementing IAlertNotificationHandler interface. You can follow the KB 948321 for instructions on how to write and implement a custom alert notification handler.

SmileTill then Happy Coding…

Comments