Delete Attachments from SharePoint list

Hello, 
I created InfoPath Form, and users can attach a file. I want to delete the attachments from the SharePoint list after a while (Privacy issues). How can I do it? I searched about it and I found some codes but I'm not sure how to use them. Could anyone help
me? 
Thank You
Dan

Hi Gary,
I would like to suggesting to used Event Receiver on that List. 
below example of how to create event receiver on list?
CREATING
EVENT RECEIVER IN SHAREPOINT 2010
another link to showing all method of  SPItemEventReceiver
event handler. you can used `ItemAdded`
or `ItemAttachmentAdded` override method to listItem.
SharePoint Event Handlers
Than used @Yaoyao Chen's Code.
code :
public override void ItemAdded(SPItemEventProperties properties)
SPListItem item= properties.ListItem;
List<string> fileNames = new List<string>();
foreach (string fileName in item.Attachments)
fileNames.Add(fileName);
foreach(string fileName in fileNames)
item.Attachments.Delete(fileName);
item.Update();

Similar Messages

  • I have huge lag with Safari's Reading List using a rMBP. I have probably 80 articles saved, which is likely the cause of the lag. Is there any way to export that list of articles so as to be able to delete them from Reading List but still have a record?

    I have huge lag with Safari's Reading List using a rMBP. I have probably 80 articles saved, which is likely the cause of the lag. Is there any way to export that list of articles so as to be able to delete them from Reading List but still have a record of the articles I intend to read?

    I'm currently dealing with this issue myself, except that my rMBP has NO articles in the reading list.  It's a brand new rMBP too, purchased just this week, with the 2.6 Ghz Processor & 16GB of RAM.
    Let's see what we can find.  I may just take it back to the Apple Store.

  • How to delete items from the list of "auto-open" tabs that load whenever FF4 opens?

    When I recently downloaded FF4, I was asked if I'd like to have FF automatically open the same tabs as were set in my IE. Great! Worked perfectly until I set those tabs as App Tabs. Now both the App Tabs and the original IE set of tabs open whenever I open FF -- essentially each tab loads twice -- as app tab and large tab. How can I delete tabs from the list of "auto-open" tabs? In addition, for some reason, every time I try to set my home page, it's not working -- I keep getting the same home page regardless of how many times I have tried to set a new one.

    You can close a tab with a middle-click or with a left click on the close X on the tab or via the right-click context menu of that tab.<br />
    Do those tabs come back if you close then and lose Firefox?

  • I accidentally deleted items from a list in reminders.  how can i retrieve them?

    i accidentally deleted items from a list in reminders.  how can i retreive them from icloud?

    From your backup.

  • Pass the username and password in URL to auto log in the application from SharePoint List

    how to Pass the  username and password in URL to auto log in the application from SharePoint List  
    I have a link  in my SharePoint list  when user try to open the link its asking username and password .i want to put username and password in URL to auto log in into that external URL from sharepoint
    please help me it is possible

    Check out
    http://serverfault.com/questions/371907/can-you-pass-user-pass-for-http-basic-authentication-in-url-parameters
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • How do I delete podcasts from my list, how do I delete podcasts from my list

    How do I delete podcasts from my list after they are deleted from my hard drive?  Some old ones have been deleted but the ones since February are still in my list waiting to be downloaded once again.  There are 2 delete options and I'm wondering which one to use.  It no longer gives me an option to delete from my hard drive.  After deleting from my list.  It seems to delete from my hard drive and then sits there.
    I would like to use automatic delete, but I need to know if I can change that to 'Save' during the 24 hour period after I'm done listening to the podcast.
    This morning everything came back in.  I noticed the settings at the top were all changed to d/l all instead of just 1.  I'm confused about this whole thing and cannot find anything in the way of a tutorial on the Apple/iTunes web site.

    Swipe left-to-right across the podcast, hit delete.

  • My iPad was stolen and I deleted it from my list of devices

    My iPad was stolen and I deleted it from my list of devices of Find my iPad by a mistake.... Is there a way to add the iPad again?

    Unfortunately, that also means the thief can now activate it because Activation Lock is no longer active.

  • When I delete a podcast, it immediately reappears with the icloud next to it.  How do I delete it from the list?

    What's deal?  When I delete a podcast, it immediately reappears with the icloud next to it.  How do I delete it from the list so that it stays gone?  I only want unplayed episodes.  I have tried all aspects of preferences but this does nothing to help.  I couldn't even delete an episode until I downloaded it, so I thought.  After the downloads, I deleted it only to have it reappear with the iCloud icon next to it.....Thanks for any help! 

    What is reappearing is just the list entry with the indication that it is available for download - it's not taking up any space on your computer. You can remove it by control- or right-clicking it and choosing 'delete'.
    The recent changes in iTunes have confused a lot of people. Here is a summary of the situation:
    Only the most recent episode shows when you first subscribe. In the default  'My Podcasts' view click 'Old episodes' to show earlier episodes, click 'Done' to hide them or 'Add all' to keep them there and also add them to List view.
    Alternatively, in 'List' view control- or right-click on the name of the podcast or the episode and choose 'Show old episodes' to reveal all the previous episodes.
    In both views you can now delete both downloaded or un-downloaded episodes from both views by control- or right-clicking on the name of the episode.
    In both views each episode now has a blue circle to the left showing it as unplayed. Each episode can be double-clicked to be played as a stream without downloading it first (so you don't have to wait for it to download fully). Click the cloud icon at right to download it (as you will have to to sync it to an iPod). Note that if you click the cloud icon to the right of the title of the podcast itself, rather than an episode, you will initiate a download of all episodes.

  • How to use SSIS 2014 to read from Sharepoint List ?

    Hi there,
    I have designed a simple entry form for users using List in Sharepoint 2013.
    I need to use the information to merge into my datawarehouse.
    Question :
    1. How can I setup SSIS (SQL 2014) to get the source from List in Sharepoint?
    I have tried to download the script as suggested in codeplex but it seems not working with SQL 2014 as there is no SSIS toolbar displayed.
    Any help is much appreciated
    Thank you and Best Regards

    Hi SylviaO,
    The current
    SharePoint List Adapter that extracting and loading SharePoint Data in SQL Server Integration Services supports x86/x64 systems using SQL 2005 / SQL 2008 / SQL 2008 R2/ SQL 2012. It doesn’t support SQL 2014. Maybe we need wating the update.
    Besides, the
    OData Source component can also be used to read from SharePoint lists. So we can download and install the 64 bit ODataSourceForSQLServer2014-amd64.msi or 32 bit ODataSourceForSQLServer2014-x86.msi from the
    Microsoft® SQL Server® 2014 Feature Pack.
    The following blog about using the SSIS OData Source Connector to read data from SharePoint lists is for your reference:
    http://whitepages.unlimitedviz.com/2014/03/using-the-odata-source-connector-with-sharepoint-online-authentication/
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Deleting attachments from SAP documents (FB02)

    I am in need to control the action of 'deleting/removing' attachments from documents, when entered via FB02.
    I believe the authorization object for attached documents is S_BDS_DS.
    Does anyone how to 'enable' or 'disable' this activity ?
    --- When run FB02 or FB03, at the upper corner you click on the 'Services for Object' button,
    --- Then, you select the 'Attachment List' option
    --- Next, you have a new window with a list of attachments, if any
    Within that window there is the 'delete (recycle bin) button.
    How can I activate/deactivate it ?
    Best regards,
    Tom

    Hari, thank you for your reply!
    My question is "How to enable/disable the action of deleting the attachment" ?
    Once the window that lists the attachment(s) opens up (via FB02) , how do I show / don't show the recycle bin button ?
    Best regards,
    Tom

  • Delete file from the list & as well as from file upload

    I have come across a situation where there is a sap.ui.unified.FileUploader & user is free to upload as many file selected. then there is a button to display the list of added files as list(deleteable list). list delete is possible by using the standard function provided in the explored of SAP UI5 SDK document. but how to bind both the controls?? do that at the time of deleting the list it will also delete the files added in FileUploader. attaching the screenshot for better understanding...
    SAP UI5 Version 1.24.3

    Hi,
    you can use the setValue() method when you delete a file from the list:
    oFileUploader.setValue("");
    Kind regards,
    RW

  • Delete file from the list.

    How can I delete the PDF from the list.

    See the FAQ: http://learn.adobe.com/wiki/display/readermobile/iOS+FAQ

  • I am trying to stop programs from opening automatically when I turn my computer on.  I tried system preferences users and groups login items...then I deleted them from the list but it did nothing.

    I am trying to stop programs from opening automatically when I turn my computer on.  I tried system preferences>users and groups>login items...then I deleted them itunes and emial from the list but it did nothing.  They continue to open up every time I turn on my Macbook Pro.

    Hi r,
    It sounds like you're running Lion?
    Have you tried running Verify and/or Repair Disk?
    Have you tried running Repair Permissions?
    Do you have at least 15% free space available on your HD?

  • Insert Image in SharePoint List & Display Image from SharePoint List using C# Pragmatically

    hi 
    i have a share point custom list with the following columns and its types.
    Title--------------->Single line of test 
    FirstName--------------->Single line of test
    LastName--------------->Single line of test
    Description--------------->multiple line of test
    Link--------------->Hyperlink or Picture
    Image--------------->Hyperlink or Picture
    I've to create a visual web part with the following input fields and which can insert following items in the above list columns
     Title                  asp textbox
    First Name         asp textbox
    Last Name        asp textbox
    Description        asp textbox
    Link                  asp textbox
    Image              file upload control
    Submit             asp button
    when i click browse button for image control in above web part it browses image .jpg,jpeg or .png file from my computer into image input field above and when i click submit button it must be submitted in the Image column in the above list.
    i want to know how can i do that in c# pragmatically. 
    i've another visual web part which should read the image from the list in Image column and display it in image control on the web part.
    like this
    <img id="imgdisplay" runat="server" src="" />
    how can i read image from image column through c# pragmatically.

    Hello,
    You can't directly add picture into "Hyperlink or Picture" column because this column takes URL value and image is binary etc. You can first upload that picture into picture library (create new picture or document library) then add that image link
    into that column.
    To add/edit "Hyperlink or Picture" column, SP provided special class called "SPFieldUrl". Wheer you need to pass URL and description as parameter.
    Refer this link for you ref:
    http://stackoverflow.com/questions/23829576/how-to-decide-sharepoint-url-field-is-set-as-hyperlink-or-picture
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to show data from sharepoint list in mm dd yyyy format using Server Object Model

    In SharePoint 2010
    List "Employee", Colum Name "JoinDate" 
    has stored data in  (01/31/2014 12.00 PM) mm\dd\yyyy hr:mm PM format.
    How to display this data in mm\dd\yyyy only using C# on custom web part?

    //Write the code to read your list item
    SPListItem item = list.Items[0];
    //Get a DateTime object with the list column value
    DateTime date = Convert.ToDateTime(item["Date Column Name"]);
    String strDate = date.ToString("mm-dd-yyyy hh:mm tt");
    //you can also try ("dd/mmm/yyyy")
    http://sharepoint.stackexchange.com/questions/12820/safest-way-to-get-a-date-from-sharepoint-into-a-c-datetime-field-using-object

Maybe you are looking for