Upgrading and Fixing Email Enabled Lists in SharePoint 2010

Kelly Gibson, our engineer was working on Upgrade this last weekend and found that email enabled lists stopped working. He had already updated SMTP and the MX record and so forth to ensure it was pointing to the correct box. What he was noticing was SharePoint was losing track of the email enabled lists. Email was coming in right, but wasn’t configured correctly.

In the troubleshooting steps they found that if they un enabled the list for email and then re-enabled it, it would work. 400 lists and hours and hours later this batch in the upgrade was done.

Now that we’re looking back at it, we’re thinking, there’s got to be a better way.

When I got in this morning, I jumped on my favorite resourcing tool… Twitter and reached out to the community and asked…

@Joeloleson: Had problems with upgrading SharePoint 2010 and email enabled lists? Anyone have good workaround?

Todd Klindt chimed in with

@ToddKlindt: @joeloleson You have to go into each list’s email settings and hit ok. :("

That was a good start, and would have saved us a lot of time. He went on to explain why we were seeing the issue, that apparently isn’t the problem if you have the same Configdb as in InPlace Upgrade (still not a good reason to use in place IMO)…

@ToddKlindt: @joeloleson The incoming email settings don’t get upgraded in the Config DB when you do a database attach.

Daniel Glen how would one discover the email enabled lists…

@DanielGlen: @ToddKlindt @joeloleson is there a way to find all email-enabled lists before you upgrade??

Todd replied to him with an excellent resource from Gary Lapointe the best STSADM extensions ever built. He shares his info in a post "Enumerating Email Enabled Lists via STSADM" where he gives Todd credit for getting started on this and giving Gary the inspiration. This line was the missing piece for Gary:

m_emailSuffix = SPFarm.Local.GetChild<SPIncomingEmailService>().ServerDisplayAddress.ToLower();

@ToddKlindt: @DanielGlenn I use this: http://blog.falchionconsulting.com/index.php/2008/08/enumerating-email-enabled-lists-via-stsadm/

There was some chatter about the fact that we all thought there should be a way to fix this leveraging the ultimate power of Windows Powershell. Microsoft PFE script to the rescue… Don’t you wish more of this kind of stuff would make it’s way to the surface? I’m sharing this, not taking any credit for it, not sure who wrote it, and not even saying it works. What I like about it is it tells us what is wrong and tells us what objects we can work with. This two part script detects the lists that are email enabled and are essentially broken email enabled lists missing the alias setting and the second part once you have the web and the affected list you can update it.

Now that we’ve got this sample code, someone smart can ensure this is the right fix, combine this logic and build something useful for the rest of us J

 

##Script to detect affected lists (In SharePoint 2010)

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null  

 
 

  [void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  

 
 

 $oContentService = [Microsoft.Sharepoint.Administration.SPWebService]::ContentService;  

 [Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.webApplications;  

 $waColl1 = $waColl | where-object {$_.IsAdministrationWebApplication -eq $FALSE}  

 write-host "WebApplication; Site Collection; List Title; List URL; EmailAlias" 

 foreach ($wa in $waColl1)  

 {  

 $sites = $wa.Sites  

 foreach ($obj in $sites)  

 {  

 $spSite = new-object Microsoft.SharePoint.SPSite($obj.URL)  

 $colWebsites = $spSite.AllWebs  

 foreach ($web in $colWebsites)  

 {  

 $colLists = $web.Lists  

  foreach ($list in $colLists)  

  {  

  if ( $list.EmailAlias -ne $null )  

  {  

  write-host  $wa.Name, ";", $obj.URL, ";", $list.Title , ";", $list.DefaultViewUrl, ";",  $list.EmailAlias  

 $a = $list.EmailAlias

 $a

 $list.Emailalias = $a

 $list.update()

 }  

 }  

 }  

 }  

 write-host "Finished." 

 

 

 

##Code to update the email settings

$site = Get-SPWeb <URL of the sub site>

$list = $site.Getlist("<URL of the list")>

$a = $list.EmailAlias

$a

$list.Emailalias = $a

$list.update()

 

KUDOS to Kelly Gibson for finding the issue and manual work around, Todd Klindt for giving us a better manual work around and helping spread and Daniel for asking follow up. Great twitter discussion on this topic with @BrianTJackett and Benjamin Athawes

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: