locked
Getting a list of all Email Enabled Document Libraries witin a SharePoint 2007 Web App RRS feed

  • Question

  • Hello,

    Is there an easy way possibly using powershell to get a listing of all the Email Enabled Document Libraries along with their email addresses within a SharePoint 2007 Web App?

    I would like a listing of all document libraries within 2007 that have email enabled.

    Any assistance would be of great help.

    Thanks.

    JShidell


    v/r JShidell
    • Edited by Mike Walsh FIN Thursday, January 12, 2012 10:00 AM Reference to SP 2010 removed as off-topic.
    Thursday, January 12, 2012 9:53 AM

Answers

  • For those that are interested on getting this to work.  This is what worked for me, with PowerShell.

    #Load SharePoint Asssemblies
    [System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    [System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
    [System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

    $SPwebApp = Get-SPWebApplication "http://portal/"
    #create a CSV file 
    "E-Mail,List,Site" > "EMail-Enabled.txt" #Write the Headers in to a text file
      
    foreach ($SPsite in $SPwebApp.Sites)  # get the collection of site collections
    {
    foreach($SPweb in $SPsite.AllWebs)  # get the collection of sub sites
    {
    foreach ($SPList list in $SPweb.Lists)
    {
    if ( ($splist.CanReceiveEmail) -and ($SPlist.EmailAlias) )
    {
    # WRITE-HOST "E-Mail -" $SPList.EmailAlias "is configured for the list "$SPlist.Title "in "$SPweb.Url
    $SPList.EmailAlias + "," + $SPlist.Title +"," + $SPweb.Url >> EMail-Enabled.txt  #append the data
    }
    }
    }
    }

     


    v/r JShidell
    • Marked as answer by Mike Walsh FIN Thursday, January 19, 2012 2:53 PM
    Thursday, January 19, 2012 2:47 PM

All replies

  • Native PS is available with sharepoint 2010. However if you still wish to have powershell with sharepoint 2007 you can indeed do so by installing Powershell on your MOSS machine. To do so refer  http://nickgrattan.wordpress.com/2007/09/03/preparing-powershell-for-sharepoint-and-moss-2007/ .

    Also, below is the powershell snippet to check if the document library is email enabled

     

    function GetEmailEnabledLibraries ($WebApp) 
    {
    
        $WebApplication = Get-SPWebApplication $WebApp 
        $WebApplication | Get-SPSite | Get-SPWeb  -limit all | ForEach-Object { 
                write-host "——-" 
                write-host "URL of Webs: " $_.Url 
                $lists = $_.lists 
                $lists | ForEach-Object { 
                if( ($_.CanReceiveEmail) -and ($_.EmailAlias) ){ 
                    write-host "Title of list: " $_.Title 
                    write-host "Email of list: " $_.EmailAlias 
                 } 
              }   
         }
    
    }
    

     


    Additionally, you can also achieve this using a console app utility + sharepoint object model, which, i think would be much faster and easier.

    You can get all the email enabled libraries but looping though all the libraries in the SPWEb and then  use  the properties like SPDocumentLibrary .CanReceiveEmail(true if doc lib is email enabled) and SPDocumentLibraries.EmailAlias(Email address) to get the specific list.

     


    Priyanka
    • Edited by priyanka8275 Thursday, January 12, 2012 10:40 AM
    Thursday, January 12, 2012 10:39 AM
  • Hi, below is the code for share point object model,
    	SPSite oSites = new SPSite("server/");
    			SPWeb oWebs = oSites.OpenWeb();
    
    			foreach (SPList list in oWebs.Lists)
    			{
    				if (list.CanReceiveEmail)
    				{
    					string EmailAddress = list.EmailAlias;
    				}
    
    			}
    ///  for powershell check this
    function GetLibEmail ($WebApp) 
    {
    
        $WebApplication = Get-SPWebApplication $WebApp 
        $WebApplication | Get-SPSite | Get-SPWeb  -limit all | ForEach-Object { 
                write-host "——-" 
                write-host "URL of Webs: " $_.Url 
                $lists = $_.lists 
                $lists | ForEach-Object { 
                if( ($_.CanReceiveEmail) -and ($_.EmailAlias) ){ 
                    write-host "Title of list: " $_.Title 
                    write-host "Email of list: " $_.EmailAlias 
                 } 
              }   
         }
    
    }


    Anil
    Thursday, January 12, 2012 11:22 AM
  • Hi Priyanka,

    Thanks for the info.  I have Powershell already installed on the MOSS server, however i'm running into these errors when trying to execute the script:

    Get-SPWebApplication and Get-SPSite is not recongized as the name of a cmdlet, function, script file, or operable program.

    I loaded up the assemblies, which usually fixes these errors but the errors still show up:

    [System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
    [System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

    Any ideas on how I can fix this?

    I tested to make sure the assemblies did load by doing this:

    $spsite=[Microsoft.SharePoint.SPSite](“http://localhost/sites/intranet“)
    $spsite

    And it returned successfully.

    Thanks for any assistance. 


    v/r JShidell
    Thursday, January 12, 2012 12:24 PM
  • Hi,

    Refer http://get-spscripts.com/2011/03/using-powershell-scripts-with-wss-30.html

    The above link shows the commands in moss 2007

    For ex: To get sp web application use the following powershell code

     

    $webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup(“http://portal”)
    

     


    Priyanka
    • Marked as answer by Pengyu Zhao Wednesday, January 18, 2012 7:20 AM
    • Unmarked as answer by Mike Walsh FIN Thursday, January 19, 2012 2:53 PM
    • Edited by Mike Walsh FIN Thursday, January 19, 2012 2:54 PM and sharepoint 2010 removed. Off-topic in a pre-2010 forum
    Friday, January 13, 2012 12:00 PM
  • For those that are interested on getting this to work.  This is what worked for me, with PowerShell.

    #Load SharePoint Asssemblies
    [System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    [System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
    [System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

    $SPwebApp = Get-SPWebApplication "http://portal/"
    #create a CSV file 
    "E-Mail,List,Site" > "EMail-Enabled.txt" #Write the Headers in to a text file
      
    foreach ($SPsite in $SPwebApp.Sites)  # get the collection of site collections
    {
    foreach($SPweb in $SPsite.AllWebs)  # get the collection of sub sites
    {
    foreach ($SPList list in $SPweb.Lists)
    {
    if ( ($splist.CanReceiveEmail) -and ($SPlist.EmailAlias) )
    {
    # WRITE-HOST "E-Mail -" $SPList.EmailAlias "is configured for the list "$SPlist.Title "in "$SPweb.Url
    $SPList.EmailAlias + "," + $SPlist.Title +"," + $SPweb.Url >> EMail-Enabled.txt  #append the data
    }
    }
    }
    }

     


    v/r JShidell
    • Marked as answer by Mike Walsh FIN Thursday, January 19, 2012 2:53 PM
    Thursday, January 19, 2012 2:47 PM