ItemAdded Firing Twice when dragging email attachment to windows explorer with document library folder as favorite) RRS feed

  • Question

  • Problem: 
    I have mapped a SharePoint Document Library folder to Windows Explorer.
    I'm trying to drag an attachment from Outlook to this mapped folder, and the Event Receiver should run to rename this file based on the code in ItemAdded of my Event Receiver.

    However, the above action results in 2 files being saved and renamed by ItemAdded, but 1 of them is 0KB in size:
    1. fileRenamed-001.pdf (size 0KB)
    2. fileRenamed-002.pdf (size 615KB) (the actual saved file - 2nd firing of Event)

    When I drag the same file from Windows Explorer to the Document Library on my browser, it is working fine (ItemAdded firing once, and there are no 0KB files)

    I have searched and tried most of the solutions on the web on this topic, but the ItemAdded event receiver still fires twice.

    Things I have tried:

    1. Feature.Template.xml & Feature.feature in Visual Studio
    - Set Scope to "Web"

    <Feature xmlns="" Scope="Web">

    2. Elements.xml
    - Set Synchronization to "Synchronous"


    3. Checked to see if the Event Receiver is registered twice using the following code - but ItemAdded only showed up once.

    $site = Get-SPSite
    $web = $site.OpenWeb("/path/to/my/site")
    $list = $web.Lists["The List"]
    $list.EventReceivers | Select Type, Class | Order Type, Class
    4. Deleted all the other EventReceiver Items for the List (Only EventReceiver left was ItemAdded) 

    So I'm thinking it must be the code in the ItemAdded that is causing the event to be fired twice.

    Appreciate any help on this matter. Thanks!

    • Edited by Ken Yuen Tuesday, January 10, 2017 7:53 PM removing code
    Tuesday, January 10, 2017 5:16 PM

All replies