none
event receivers

Answers

  • I have put together example code to perform the task that you are looking to perform. Please refer to the example code that I have provided. I hope this helps, and please mark this as an answer if it does.


    public override void ItemAdding(SPItemEventProperties properties)
    {
        base.ItemAdding(properties);
        string emailTo = String.Empty;

        foreach(SPUser user in properties.Web.SiteAdministrators)
        {
            emailTo += user.Email + ";";
        }
        
        emailTo.RemoveAt(emailTo.LastIndexOf(';'));

        SPUtility.SendEmail(properties.Web, true, true, emailTo, "Your Subject", "Your Email Body");
    }

    Thanks!

    Andrew Christen

    EPC Group.NET - Sr. SharePoint Developer/Architect

    Monday, July 22, 2013 3:23 AM

All replies

  • Use the ItemAdding event

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.itemadding.aspx

    Mind you that this will be a nuisance and a headache for the system admin. Unless you are sure about what your requirements are ... i would say its really a bad idea to send a message to a sysadmin everytime a document is added to SharePoint.

    so I hope you know what you are doing...


    val it: unit=()

    Monday, July 22, 2013 2:57 AM
  • Or the site admin can just use the Alerts feature.
    Monday, July 22, 2013 3:15 AM
  • I have put together example code to perform the task that you are looking to perform. Please refer to the example code that I have provided. I hope this helps, and please mark this as an answer if it does.


    public override void ItemAdding(SPItemEventProperties properties)
    {
        base.ItemAdding(properties);
        string emailTo = String.Empty;

        foreach(SPUser user in properties.Web.SiteAdministrators)
        {
            emailTo += user.Email + ";";
        }
        
        emailTo.RemoveAt(emailTo.LastIndexOf(';'));

        SPUtility.SendEmail(properties.Web, true, true, emailTo, "Your Subject", "Your Email Body");
    }

    Thanks!

    Andrew Christen

    EPC Group.NET - Sr. SharePoint Developer/Architect

    Monday, July 22, 2013 3:23 AM