Send Sharing Link for Sharepoint Folder

Occasional Contributor

I have been battling with this for a few days now... I am using CSCOM to connect to SharePoint. Everything is working fine, creating folders and uploading files. However, I now need to create a shared folder (parent level) link for external users and then initiate the email invite as per the "links giving access" not direct access. I can create and send an anonymous link but this is not what we are after.

string s = "password";
SecureString passWord = new SecureString();
foreach (var c in s)

string siteURL = "siteurl";
string parentFolder = "parentfolder";

using (Microsoft.SharePoint.Client.ClientContext CContext = new Microsoft.SharePoint.Client.ClientContext(siteURL))
CContext.Credentials = new SharePointOnlineCredentials("",passWord);
var subFolders = CContext.Web.GetFolderByServerRelativeUrl(parentFolder).Folders;

<<create sharing link for parent folder and send email to external user>>>

foreach (var subFolder in subFolders)


The above code iterates thru the sub folders of the parent, this is me just making sure I am getting the right data. But I can't seem to find anything that allows me to create the sharing link and send to an external user so they get an invite etc...

If I add in the following, it creates an invite but adds the user to the entire site via Direct Access ... not by link to the folder....

var users = new List<UserRoleAssignment>();
users.Add(new UserRoleAssignment()
UserId = "",
Role = Role.View

WebSharingManager.UpdateWebSharingInformation(CContext, CContext.Web, users, true, "You've been invited...", true, true);

Any help would be appreciated.

Many thanks

0 Replies