Using PowerShell to Manage SharePoint Email Settings

Each SharePoint Document Library is capable of accepting Incoming Email.  Here is how to manage the settings via PowerShell.

In SharePoint 2010, the SharePoint Management Shell must run as the Application Pool account when setting the EmailAlias property.  Other properties can be set as a standard Shell Admin user.

First, bind to the Web and the List:


When making a change to a list property, make sure to call the Update() method, for example:

Here are the various settings you can apply.  I’ll be translating from the SharePoint UI to the PowerShell property.

EmailLibrary

 

[divider]

E-mail address (note this also sets Allow this document library to receive e-mail?)

Group attachments in folders?

Overwrite files with the same name?

Save original e-mail?

Save meeting invitations?

E-mail security policy:

To disable Incoming Email on a Library, simply run:

 

3 Comments

  1. In Sharepoint 2013, I receive this error when calling the $list.Update(); method

    Exception calling “Update” with “0” argument(s): “Error in the application.”
    At XXXXXXXXXXXXXXXXXXXXXXXXXXXx
    + $list.Update();
    + ~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SPException

  2. Is there any way to find out what email adresses are defined?
    I found only the powershell way, so if anyone else has to check on what email recipients your farm is listening to, feel free to reuse:

    Get-SPSite -Limit All | ForEach-Object {
    foreach($currentWeb in $_.AllWebs) {
    foreach($currentList in $currentWeb.Lists) {
    if ($currentList.EmailAlias -ne $null) {
    write-host “Found email address >” $currentList.EmailAlias “” $currentList.Title “” $currentWeb.Url “<"
    }
    }
    }
    }

  3. If the property already exist you can set it using the following (example):


    $root = list.RootFolder
    $root.Properties.vti_emailsaveoriginal = 1
    $root.Update()

Leave a Reply