none
Document library Incoming Emails with same subject RRS feed

  • Question

  • Hi,

    we have enabled Incoming email setting for a document library. We noticed an issue. When there are 3 or more emails with same subject, some emails are getting discarded.

    We think it is because Sharepoint takes the subject and appends date and time to it,and uses it as name for the item.

    When 2 emails with same subject are processed at same time SharePoint either replaces the 1st  email or discards the 2nd email depending on the Overwrite files (vti_emailoverwrite) setting for the libraray.

    This way we are losing some emails. Is there a solution for this?

    Thanks,

    Arun 

    Tuesday, January 31, 2017 4:22 PM

All replies

  • Hi Arun,

    I tested this case in my environment and figure it out that it creates the folder with single subject and keep all other emails within it.  you can enable the document versioning and you can have different emails with same name but have different version.

    As per the unique file name and to have a specific URL it is by designed in document library only one file with one name. If you had two files with the same name in the same folder you couldn't have unique URLs for files in document libraries. Document sets are just glorified folders you can have multiple folders but again in each folder you can have a single file with a name.

    Once you click on folder you have all emails with same subject within as below.

    You could develop an item adding event receiver that checks the file name and changes it if duplicates are found and can append anything as per your wish to make available the same subject email but have different file name here you can create another column in the library like Actual Subject and copy your Name value to this column to having all same subject email with one name if you want.


    KRISHANA KUMAR

    SharePoint Architect

    Mosstechnet-kk.com

     

    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful

    Tuesday, January 31, 2017 5:30 PM
  • Hi Krishana,

    Thank you for your response.

    For us the emails with same subject are not going into a separate folder. And also as per your screenshot I see emails are appended different numbers at the end. Can I know if this configurable?

    My exact issue is if there are 5 or 6 emails in the SMTP drop folder, SharePoint timer job picks them in one go and then while it inserts them into a document library, 2 or 3 emails are having same name and it either replaces/ discards.

    I sent 6 emails bur sharepoint inserted only 4. I think whats happening is SharePoint tried to append 2017--3-50-14 or 15 for the other emails and treats them as duplicates.

    Thanks,

    Arun


    • Edited by Arun_Pasham Wednesday, February 1, 2017 9:22 AM image was not visible
    Wednesday, February 1, 2017 9:21 AM
  • Hi,

    If you send 6 same emails to SharePoint library in the same time, the 6 emails will be routed to drop folder but SharePoint timer job picks 6 emails but only 4 emails show in library. Am I right?

    It’s an expected behavior in SharePoint. The date and time doesn’t contain seconds and library is not supported to display files with same name in SharePoint.

    You can submit your feedback about issue via Uservoice. This is the best way to influence our products.

    Best Regards,

    Dean Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, February 1, 2017 11:13 AM
    Moderator
  • Hi Arun,

    As Dean said it is product by design so we don’t have control out of the box to control multiple emails with same subject and on same time, you can write the event receiver for the document library that will check the mail subject and if it is same you can give the different name as you have much control in code, even you can create other column and where you can copy the same subject value.

    In your case you have to use email event receiver as Item Added (and Item Adding) event receivers are not triggered by incoming emails in document library.

    There are specific event receivers for handling email events which should give you the functionality you require: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spemaileventreceiver(v=office.15).aspx

    You can write code to check the subject of the incoming email and update column value

    namespace Example_Namespace
    {
        public class Email_Handler: SPEmailEventReceiver
        {
            public override void EmailReceived(
                SPList oList,
                SPEmailMessage oMessage,
                string strReceiverData)
            {
                SPListItem oListItem = oList.Items.Add();
                oListItem["Title"] = oMessage.Headers["Subject"];
                oListItem["Body"] = oMessage.HtmlBody;
                oListItem.Update();
            }
        }
    }
    
    
    Here is example with steps to create email event receiver and how to deploy to SP site.
    https://pholpar.wordpress.com/2010/01/13/creating-a-simple-email-receiver-for-a-document-library/
    
    
    https://blog.josequinto.com/2014/11/06/how-to-attach-an-event-receiver-for-an-specific-list-in-sharepoint-2013/

    KRISHANA KUMAR

    SharePoint Architect

    Mosstechnet-kk.com

     

    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful

    Thursday, February 2, 2017 2:43 PM

  • it is possible to use different approach: event sinks (see e.g. SMTP event sinks under Windows Server 2008 R2). Idea is that you may attach script to its event (OnArrival) which will add unique timestamp to the email subject. Alternatively you may add listener to the drop folder using FileSystemWatcher class (How can I monitor a Windows directory for changes) and modify subject when email arrives there - however i nthis approach there is no 100% guarantee that your code will be executed before Sharepoint timer job will cleanup the drop folder.

    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    Thursday, February 2, 2017 5:18 PM
  • Hi Arun,

    Can you please let us know how you have appended time and date at the end of the email. Is it by an SPEmailEventReceiver or is there an OOTB property?

    Best Regards,

    IpKov



    • Edited by IpKov Monday, November 19, 2018 7:29 AM
    Monday, November 19, 2018 5:14 AM