Tell me how to delete attachments selectively , i.e. how to correctly write a function that will delete the selected attachment.