none
Enabling Incoming Email throws opaque error

    Question

  • The following code (in PowerShell):


    $DiscussionsList = $ClientWeb.Lists["Discussions"];
    $DiscussionsList.EmailAlias = $LowerDomainNameWithoutSuffix + "-archive";
    $DiscussionsList.ContentTypesEnabled = $true;
    $DiscussionsList.Update();

     

    $RootFolder = $DiscussionsList.RootFolder;
    $RootFolder.Properties["vti_emailsaveattachments"] = 1;
    $RootFolder.Properties["vti_emailsavemeetings"] = 0;
    $RootFolder.Properties["vti_emailsaveoriginal"] = 0;
    $RootFolder.Properties["vti_emailusesecurity"] = 0;
    $RootFolder.Update();


    Results in the following being thrown at $DiscussionList.Update():

     

    Microsoft.SharePoint.SPException: Error in the application.
       at Microsoft.SharePoint.SPList.UpdateDirectoryManagementService(String oldAlias, String newAlias)
       at Microsoft.SharePoint.SPList.Update(Boolean bFromMigration)
       at Microsoft.SharePoint.SPList.Update()

     

    Not the most helpful error. Smile  Does anyone have any thoughts as to root cause?  It is being run from Windows PowerShell using an administrative account.

     

    Thanks,

    Colin

    Wednesday, June 18, 2008 5:01 PM

Answers

  • File this one under "frustrations with SharePoint".  After using Reflector to dig into the UpdateDirectoryMangementService method I noticed that it would throw a generic SPException when the result from the web service was anything but Success or PendingApproval.  Next I popped open Fiddler to find that the call was to SharePointEmailWS.asmx which is a class by the same name in stssoap.dll.  Looking at that class the code logic you get the following:

     

        if (User is an Application Pool Accounts)
        {
            Create Contact and return Status
        }
        return Access Denied

    Even though I am the domain admin running the script it would not complete because I was not one of the application pool accounts.  Subsequently I ran it in a PSH instance using the SharePoint application pool credentials and it worked.

     

    Whomever decided to throw a generic exception with no reason attached to it really needs to be shown how to properly instrument code to ensure others can build off of it because this was a real pain to have to dig for.  I hope this helps some other poor soul who is digging to find out what there is an "error in the application".

     

    Thanks,
    Colin

    Wednesday, June 18, 2008 5:53 PM

All replies

  • File this one under "frustrations with SharePoint".  After using Reflector to dig into the UpdateDirectoryMangementService method I noticed that it would throw a generic SPException when the result from the web service was anything but Success or PendingApproval.  Next I popped open Fiddler to find that the call was to SharePointEmailWS.asmx which is a class by the same name in stssoap.dll.  Looking at that class the code logic you get the following:

     

        if (User is an Application Pool Accounts)
        {
            Create Contact and return Status
        }
        return Access Denied

    Even though I am the domain admin running the script it would not complete because I was not one of the application pool accounts.  Subsequently I ran it in a PSH instance using the SharePoint application pool credentials and it worked.

     

    Whomever decided to throw a generic exception with no reason attached to it really needs to be shown how to properly instrument code to ensure others can build off of it because this was a real pain to have to dig for.  I hope this helps some other poor soul who is digging to find out what there is an "error in the application".

     

    Thanks,
    Colin

    Wednesday, June 18, 2008 5:53 PM
  • I may have submitted the bug in the wrong spot but I posted this to connect today and then started searching if anyone else was bitching about this, the exception handling in the web services seem to be very unprofessional at best, if not reckless, who reviewed this code?  What is scarier is their set of services seemed to be named logically, Lists, Webs etc and then all of the sudden one new one for directory management and it's called SharepoingEmailWS, wtf?  Was this outsourced and then just slapped in at the end?

    https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=435242&SiteID=428
    • Proposed as answer by Azra Ansari Wednesday, November 10, 2010 7:37 AM
    Saturday, April 25, 2009 11:19 PM
  • I  am using the account as application pool accunt , still getting the error
    Wednesday, November 10, 2010 7:42 AM