How to Delete SharePoint List attachements using CSOM in SharePoint Online/Office 365?

Hello SharePointers,

Below is the CSOM Code snippet to delete SharePoint list attachments in SharePoint Online/Office 365.

public static void DeleteAttachmentFilesfromListItem(ClientContext cc, string listName,int listItemId)
var list = cc.Web.Lists.GetByTitle(listName);
var listItem = list.GetItemById(listItemId);
cc.Load(listItem, li => li.AttachmentFiles);
listItem.AttachmentFiles.ToList().ForEach(a => a.DeleteObject());


Happy SharePointing :-)(


Leave a Reply

Your email address will not be published. Required fields are marked *