Showing posts with label Outlook. Show all posts
Showing posts with label Outlook. Show all posts

Sunday, September 17, 2017

Outlook Calendar Sharing Error Message

When you use Outlook to share a calendar with another user, you might get one of the following errors:
  • Calendar sharing is not available with the following entries because of permission settings on your network;
  • You cannot request to share calendars with the following people because of permission settings on your network.


This typically happens when users type the recipients’ email address or use the address from their cached addresses. When this happens, clear the cached entry for the user, click the TO button and select the intended recipient(s) from the address book.

Tuesday, April 18, 2017

Block all Outlook versions earlier than X version

For one reason or another, some organizations have the requirement to block older versions of Outlook from connecting to their Exchange environment. This can easily be done on a per-mailbox or on a per-mailbox server basis.

Let’s say we want to block user nuno from accessing his mailbox using all Outlook versions earlier than 11.8010.8036. To achieve this, we run the following cmdlet:
Set-CASMailbox nuno -MAPIBlockOutlookVersions "-11.8010.8036"

When the user tries to use an older version of Outlook, he will get the following message (in this case I blocked all versions of Outlook):

Followed by:

To restore access to the mailbox to any version of Outlook, we simply clear the MAPIBlockOutlookVersion parameter:
Set-CASMailbox nuno -MAPIBlockOutlookVersion $null

To achieve the same but on a per-server basis, we need to use a Registry Key on all servers. In the next example, we create the Disable MAPI Clients registry value to block access to all mailboxes for Outlook clients prior to version 14.0.0:
New-ItemProperty "HKLM:\System\CurrentControlSet\Services\MSExchangeIS\ParametersSystem" -Name "Disable MAPI Clients" -PropertyType String -Value "0.0.0-5.9.9, 14.0.0-"

Important: be careful when restricting client access because server-side Exchange components must also use MAPI to log on. Some components report their client version as the component name (such as SMTP or OLE DB), while others report the Exchange build number (such as 6.0.4712.0). For this reason, we must avoid restricting clients that have version numbers that start with 6.x.x.

Tuesday, November 1, 2016

Cannot expand the folder. The set of folders cannot be opened.

The other day a user was having problems accessing a meeting room’s mailbox in Outlook. Whenever she tried to expand its folder list, she would get the following error:

Cannot expand the folder. The set of folders cannot be opened. Microsoft Exchange is not available. Either there are network problems or the Exchange server is down for maintenance.


First thing I tried was to remove and re-add the permissions, but to no vail:
Remove-MailboxPermission meeting.room@domain.com -User Linda -AccessRights FullAccess -InheritanceType All

Add-MailboxPermission meeting.room@domain.com -User Linda -AccessRights FullAccess -InheritanceType All


Second thing I tried was removing the permissions once again, but this time re-adding them without auto mapping:
Add-MailboxPermission meeting.room@domain.com -User Linda -AccessRights FullAccess -InheritanceType All –AutoMapping:$False

Then I manually added the mailbox via Account Settings. This seemed to have worked as the user could now expand the folders! However, when I closed and reopened Outlook the issue came back...


Third thing I tried was to use OWA to access the mailbox and everything worked fine! OK, seems to be a problem with Outlook itself. However, after creating a new profile, the issue was still there...
So, I decided to also give same access to a couple of other users and they all had the same problem (independently if they were in Online or Cached mode).

Time for some digging! Since this issue was all about Outlook, the first place I decided to look was in the RPC Client Access logs (or RCA logs), located by default at C:\Program Files\Microsoft\Exchange Server\V15\Logging\RPC Client Access


In these logs I found the following entry (multiple times) in the Failures column for the user:
RopHandler: Logon: [RopExecutionException] Couldn't find a mailbox for MailboxId: Dn[/o=EXCHANGE/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Meeting Room] in the current forest. The client should attempt to re-discover it.. Error code = UnknownUser (0x000003EB) -> [ObjectNotFoundException] The Active Directory user wasn't found.


Next, I used the Get-Mailbox and Get-ADUser cmdlets to search for the Distinguished Name of “/o=EXCHANGE/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Meeting Room” but couldn’t find it anywhere. There were a couple of X500 addresses for this mailbox, but none with this exact DN.

This meeting room was created years ago on Exchange 2010 and migrated to 2013. Like many other resource mailboxes in this particular environment, their naming convention is just awful and inconsistence, which made me think that I wouldn’t be surprised if somehow someone changed/deleted something they shouldn’t have...

Once I added a X500 address to this room with a value of “/o=EXCHANGE/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Meeting Room” the issue got fixed!

Saturday, June 18, 2016

Undo Ignore Conversation in Outlook

Outlook has a great feature that allows us to “ignore” particular email conversations that do not really interest us without asking the sender(s) to remove us from future emails. When we select Ignore on an email message, Outlook deletes that email and it also keeps track of all future emails related to the ignored message. If a future email related to the originally ignored email arrives in our Inbox, Outlook automatically moves these future emails to our Deleted Items folder.
 
But how about if we no longer want to ignore a particular conversation? Easy! Simply remove the “ignore” status of the email thread using the following steps:
    1. Select your Deleted Items folder;
    2. Select the email that is currently set to be ignored by Outlook;
    3. Click Ignore on the Delete section of the Home tab on the ribbon:
 
    4. If prompted, click Stop Ignoring Conversation:

 At this point, the email is automatically moved from our Deleted Items folder to the folder from which the it originated, and future emails for this thread will not be automatically deleted.

We can determine if an email is being ignored by the status of the Ignore button in the ribbon. If the Ignore button is highlighted (as in the screenshot above), the conversation thread on that email is currently being ignored by Outlook.

When we enable the Ignore option on a conversation, a message is created in the Associated Contents table of the Conversation Action Settings folder of our mailbox (which we can look at using MFCmapi for example):


It is important to have the following in mind:
  • If there is no activity on a thread for 14 days, the conversation action message for the thread is automatically deleted;
  • The age of the conversation action message is determined by the oldest message for the conversation;
  • We can modify the number of days at which the conversation action messages expire using the following registry data:
    • Key: HKEY_CURRENT_USER\Software\Microsoft\Office\x.0\Outlook\Options\Conversations
    • DWORD: OnGoingActionsExpiration
    • Value: integer specifying the number of days after which an inactive conversation has its conversation action message deleted.
  • We can start Outlook using the following switch to delete all conversation action messages: Outlook.exe /CleanConvOnGoingActions. Using this switch will not move emails back to their original location, but because the conversation action message no longer exists for the conversation, any new messages for the conversation will remain in the Inbox;
  • We can also get different behavior from this feature, depending on the version of Exchange being used:

o   With Exchange 2007 and a cached mode profile, Ignore is based on SUBJECT. For example, any message with “Help!” as the subject will be automatically sent to Deleted Items as long as we clicked Ignore for a previous message with Help! as the subject;

o   With Exchange 2010 and later versions, Ignore is based on the CONVERSATION ID and only the messages related to the same ignored conversation are automatically sent to the Deleted Items folder.

 

Friday, April 29, 2016

Outlook Chinese NDR

There is a known bug with Outlook 2010 and 2013 that causes Non Delivery Reports (NDR) to be converted to Chinese-like characters when they are forwarded:


The same NDR does not get converted when being forwarded using OWA or when forwarded as an attachment.

The good news is that there are updates to fix this:

Wednesday, January 27, 2016

Unable to Download Offline Address Book

The other day I was troubleshooting an issue where users were not able to download the Offline Address Book (OAB). After some troubleshooting steps, I ran the Outlook AutoConfiguration Test and noticed that the URL for the OAB was not listed:


Looking at the properties of the OAB, I noticed that Global Web Distribution was disabled and Virtual Directories was empty:


So what do these two properties do exactly?
  • GlobalWebDistributionEnabled specifies whether distribution occurs to all virtual directories in the organization. If the value of the GlobalWebDistributionEnabled parameter is $True, distribution occurs to all virtual directories in the organization, and we cannot add values to the VirtualDirectories parameter;
  • VirtualDirectories specifies the array of OABVirtualDirectory objects. If this parameter is specified, Version4 of the OAB must be generated.

Because, for some strange reason, none of these properties was set, there was no virtual directory for users to download the OAB from.

Remember that in Exchange 2013:
  • OAB files are not stored locally on the CAS;
  • OAB files are generated and stored in the Organization Mailbox first and later copied to the %ExchangeInstallPath%\ClientAccess\OAB\ folder on the Mailbox server responsible for generating the OAB;
  • CAS 2013 proxies all OAB download requests to the appropriate Mailbox server (the one above);
  • Outlook receives OAB URL from Autodiscover and reaches designated CAS 2013 through OAB URL.

So, without OAB URL users simply do not know where to go to get the OAB! Depending on the environment, we now have two options. The first is to specify which virtual directory(ies) to use:


Or simply enable Global Web Distribution:



After resetting IIS (or recycling the OAB application pool), if we run the Outlook AutoConfiguration Test again we should see the OAB URL:


To further test the OAB, beside manually downloading it in Outlook, you can write down the OAB URL, paste it into the address box in Windows Internet Explorer, add /OAB.xml to the end of the path, and then press Enter. The following is an example of what the URL and response resembles:
 
https://mail.domain.com/OAB/6b7ccc1d-7313-453b-9870-5e4708068e95/OAB.xml

Outlook 2016 New Sync Slider Options

With Outlook 2013 we saw the introduction of the Sync Slider, which helps limit the size of OST’s by controlling how much recent mail was synchronized locally on the device. For Exchange accounts, this was 12 months by default, with the option to go down to 1 month or up to all mail.

In Outlook 2016, Microsoft added more sync options that allow for better storage management by only retaining this much mail on the device:
• 3 days;
• 1 or 2 weeks;
• 1, 3, 6, 12 or 24 months;
• All.

 
As before, this setting can also be adjusted using Group Policy.

Restricting Outlook Clients to Cached Mode

Some organizations prefer all Outlook clients to connect to their Exchange servers using Cached Exchange Mode (also known as offline mode) because clients in Online Mode can generate significantly more disk I/O traffic. Besides using Group Policy to control this from the client side, in Exchange 2007, 2010, 2013 and 2016 we can force all clients to use Cached Mode at the server end by running the following cmdlet:
Get-Mailbox | Set-CASMailbox -MAPIBlockOutlookNonCachedMode $True

The Set-CASMailbox cmdlet is used to configure client access settings on a mailbox. For example, we can configure settings for ActiveSync, Outlook, Outlook on the web, POP3, and IMAP4. The MAPIBlockOutlookNonCachedMode parameters, which is available only in on-premises Exchange servers, controls access to the mailbox by using Outlook in online or offline mode. Valid values for this parameter are:
  • True: only Outlook clients that are configured to use Cached mode are allowed to access the mailbox;
  • False: the state of the Cached mode setting is not checked before Outlook clients are allowed to access the mailbox (both online and cached mode are allowed). This is the default value.

However, be careful with this setting! If there are Outlook clients currently configured in Online mode and you set this parameter to True, they will receive the following error message and will not be able to connect until they change their Outlook profile to Cached mode:
 

Sunday, November 11, 2012

Default Junk E-Mail folder moved to a subfolder of Journal

A while back got a user saying he wasn’t receiving some e-mails. Straight away I asked for an example and searched the Message Tracking Logs for the e-mail, only to confirm it had been delivered.
Luckily for me, my search revealed something really useful too:
 
RunspaceId : b1156ba1-602e-434f-97c2-14822536234c
Timestamp : 05/11/2012 08:48:23
ClientIp :
ClientHostname : xxxxxxx
ServerIp :
ServerHostname : xxxxxxx
SourceContext : 08CE8549B7FC9C12;2012-11-05T08:48:23.828Z;0
ConnectorId :
Source : STOREDRIVER
EventId : DELIVER
InternalMessageId : 4039958
MessageId : <210c68f5fb76da439a65309fd835991f0c7ce3 data-blogger-escaped-nat10exc01="nat10exc01">
Recipients : { xxxxxxx@domain.com }
RecipientStatus : {Junk E-mail}
TotalBytes : 20527
RecipientCount : 1
RelatedRecipientAddress :
Reference :
MessageSubject : RE: Wednesday
Sender : xxxxxxx@external.domain.com
ReturnPath : xxxxxxx@ external.domain.com
MessageInfo : 2012-11-05T08:48:23.000Z;SRV=xxxxxxx.domain.com:TOTAL=0;SRV=xxxxx.domain.com:TOTAL=0
MessageLatency : 00:00:00.9060000
MessageLatencyType : EndToEnd
EventData : {[MailboxDatabaseName, mdb33], [DatabaseHealth, -1]}


The e-mail was delivered to the Junk E-mail folder (look at RecipientStatus)! :) Ok, job done! Not exactly... When I went to the user’s mailbox to check a couple of e-mails to see if they were actually Spam, I couldn’t find the Junk E-mail folder! For some strange reason, it got moved to inside the Notes folder!...



So, how do we move it back?! If you try to move any of the default folders like Inbox, Deleted Items, etc., you will simply receive an error message.
The only way to move these is to use MFCMapi:
1. Download MFCMAPI
2. Launch MFCMAPI
3. Go to Session -> Logon and Display Store Table
4. Select the outlook profile of the user and double-click “Mailbox - User Name”
5. Expand “Root Container”
6. Expand “Top of Information Store”
7. Locate Junk E-mail, right click it and select Copy
8. Highlight “Top of Information Store”, right click it and select Paste
9. Click OK
10. Check “COPY_SUBFOLDERS” and “FOLDER_MOVE” and click OK

Hope this helps!

Wednesday, July 4, 2012

Troubleshooting Outlook Calendar Problems

If your users are experiencing issues with their Outlook Calendar, Microsoft released back in May a tool to help administrators in these situations, the Calendar Checking Tool for Outlook (also known as CalCheck).

This is a command-line tool that opens an Outlook profile on the local machine, opens the Outlook Calendar and checks permissions, free/busy information and auto booking, for example. The tool then checks each item in the calendar for any problems.

The calendar to by analyzed must reside on an Exchange Server and this tool does not work with IMAP, POP3 or any other non-Exchange mail servers.

To download it go to this link.

Tuesday, February 14, 2012

Microsoft Outlook Configuration Analyzer Tool


Microsoft just released the Outlook Configuration Analyzer Tool (OCAT ), which provides a quick and easy method to analyze your Outlook profile for common configurations that may cause problems.

This first version of OCAT allows you to do the following:
  • Scan your computer;
  • Open a previously run scan on your computer;
  • Import a scan from another computer;
  • Use several reporting formats to view the scan results ;
  • Start the Exchange Remote Connectivity Analyzer tool;
  • Send feedback to the OCAT team.

System requirements
Before you install OCAT, make sure that your computer meets the following system requirements.
Supported operating systems:
  • Windows 7
  • Windows Vista Service Pack 2
  • Windows XP Service Pack 3

This download works with the following Microsoft Office programs:
  • Microsoft Office Outlook 2007
  • Microsoft Outlook 2010 (32-bit or 64-bit)

You also need (minimum version) Microsoft .NET Framework Version 2.0
Be aware that you must make sure that Outlook is running before you start an OCAT scan!

The document that comes with the download covers really well everything that there is to know with this tool, so I will just post here some examples of what I got when I ran it on my Outlook profile.

Just like ExTRA and ExBPA, there are 3 report types: List Reports, Tree Reports and Other Reports.

When in List Reports, you have an “easy to read” view of Informational Issues, All Issues and Critical Issues:




Tree Reports gives you a more detailed a technical view:


Like I said, OCAT’s manual covers these in great detail, so I just wanted to put here a few example so you know what to expect.

DOWNLOAD: you can find OCAT here.

Wednesday, February 8, 2012

Infinite Loop of Nested Folders


A few weeks ago one user moved a subfolder of her Inbox into another subfolder beneath that one, which triggered the creation of an “infinite” loop of nested subfolders:


I tried to recreate this behaviour but every time I would get the following error (as one would expect):


So I am still not sure how all this happened... Anyway, time to delete those folders! And this is where it got interesting... First thing I tried was obviously to give myself FullAccess permissions to the mailbox and delete the folders myself. However, Outlook returned the following error:


4,000?! Humm... Let’s see how many items are in these folders and how many folders in total. To do this, I used the following two cmdlets (most output removed for simplicity):

[PS] C:\> Get-MailboxFolderStatistics “user” | ? {$_.FolderPath -eq "/Inbox/Pictures of Y"}
Name                              : Pictures of Y
FolderPath                        : /Inbox/Pictures of Y
FolderType                        : User Created
ItemsInFolder                     : 0
DeletedItemsInFolder              : 0
FolderSize                        : 0 B (0 bytes)
ItemsInFolderAndSubfolders        : 0
DeletedItemsInFolderAndSubfolders : 0
FolderAndSubfolderSize            : 0 B (0 bytes)

[PS] C:\> (Get-MailboxFolderStatistics “user”).Count
2922

Ok, so excluding all the default folders and the ones manually created by the user, there’s “only” around 2,890 folders with nothing on them. So why the error about the 4,000 limit?! Time to troubleshoot and get rid of these annoying folders!


Attempt 1
Although I had FullAccess permissions to the mailbox, decided to use ExFolders to grant myself Owner permissions on the top folder and all the subfolders. After almost 1h of propagating the permissions throughout all folders, still got the same error when trying to delete them using Outlook...

Noticed that after trying to delete the folders in Outlook, I would get the following error in the Application log of the Mailbox server (using my account to access the user’s mailbox):
Mapi session "a7198e9f-265f-4e94-b63d-7ee3d78c00c3: /o=domain/ou=exchange administrative group (fydibohf23spdlt)/cn=recipients/cn=motan" exceeded the maximum of 500 objects of type "objtFolder".


Attempt 2
Tried to delete the folders using OWA but a similar result...


Attempt 3
Tried exporting the mailbox to a PST file but it wouldn’t export it because of the folders... The export reaches 100%, then it goes down to 5%, then up again, until it eventually fails.
Tried excluding the top folder from the export using the following cmdlet:

New-MailboxExportRequest "user" -FilePath “\\server\F$\PSTs\user.pst” -ExcludeFolders “#Inbox#/Pictures of Y”

But it still didn’t work. I am not sure if the ExcludeFolders parameter also excludes subfolders or not... Both failed with the following message:
Error: MapiExceptionPartialCompletion: Unable to copy to target. (hr=0x40680, ec=0)
Operation: ISourceFolder.CopyTo
OperationSide: Source
Primary (c0e7ee8d-6f43-430a-b11f-dfba42501ee6)
PropTags: [ContainerContents; FolderAssociatedContents; ContainerHierarchy; DisplayName; RulesTable; 1071710466]


Attempt 4
Tried deleting the folders with MFCMapi but got the following error:


Attempt 5
Tried using Microsoft Exchange Server Information Store Viewer (MDBVU32) but it didn’t work as well. I wasn’t getting any errors and could create and delete other folders, but not the ones I wanted to...

MDBVU32 works “a bit” like MFCMapi. You basically logon and open the Message Store you want to access and then look for the folder (or e-mail) you want to work on.

You then change the operation to DeleteFolder() and click on Call Function... Select the flags you want and then click OK.

In my case nothing would happen for these folders although it would work for any other folders/e-mails...


Attempt 6
Thought about creating another mailbox and simply copy everything across but this would have an impact on the user and the categories wouldn’t be moved, so out of the question for now...


Attempt 7
Changing the type of the folder using MFCMapi:
  • Start MFCMapi with Outlook not set to cached mode;
  •  Logon and display store table;
  • Open mailbox/Top of Information Store;
  •  For an email sub folder that you want to delete;
  • Change PR_CONTAINER_CLASS to IPF.IMAP from IPF.Note;
  • Click OK in the property pane.

 But still the same error when deleting both from MFCMapi and Outlook...


Attempt 8
Isinteg was out of the question as it would take days to run on the DB where the user is and would affect everyone on that DB. So tried moving the mailbox to another DB but it didn’t work... After more than 3h always in 5%, it finally failed with the error (some output removed for simplicity):

Alias                            : user
Status                           : Failed
StatusDetail                     : FailedMAPI
BadItemLimit                     : 5000
BadItemsEncountered              : 0
OverallDuration                  : 04:38:45
TotalFailedDuration              : 03:25:37
TotalQueuedDuration              : 00:00:03
TotalInProgressDuration          : 01:13:04
TotalTransientFailureDuration    : 00:31:19
TotalMailboxSize                 : 1.23 GB (1,320,399,499 bytes)
TotalMailboxItemCount            : 25749
BytesTransferred                 : 0 B (0 bytes)
ItemsTransferred                 : 0
PercentComplete                  : 5
FailureCode                      : -2147024882
FailureType                      : MapiExceptionNotEnoughMemory
FailureSide                      : Source
Message                          : Error: MapiExceptionNotEnoughMemory: Unable to synchronize manifest. (hr=0x8007000e,
                                    ec=1008)
                                   Diagnostic context:
                                       Lid: 55847   EMSMDBPOOL.EcPoolSessionDoRpc called [length=142]
                                       Lid: 43559   EMSMDBPOOL.EcPoolSessionDoRpc returned [ec=0x0][length=739][latency
                                   =46]
                                       Lid: 23226   --- ROP Parse Start ---
                                       Lid: 27962   ROP: ropOpenFolder [2]
                                       Lid: 27962   ROP: ropIncrCfg [112]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropFXSrcGetBufferEx [156]
                                       Lid: 17082   ROP Error: 0x3F0
                                       Lid: 23137
                                       Lid: 21921   StoreEc: 0x3F0
                                       Lid: 27962   ROP: ropExtendedError [250]
                                       Lid: 1494    ---- Remote Context Beg ----
                                       Lid: 1238    Remote Context Overflow
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 6131    StoreEc: 0x3F0
                                       Lid: 22184
                                       Lid: 24312   StoreEc: 0x3F0
                                       Lid: 22360
                                       Lid: 2238    StoreEc: 0x3F0
                                       Lid: 20888
                                       Lid: 24504   StoreEc: 0x3F0
                                       Lid: 24148   StoreEc: 0x3F0
                                       Lid: 23796
                                       Lid: 2478    StoreEc: 0x3F0
                                       Lid: 1750    ---- Remote Context End ----
                                       Lid: 26849
                                       Lid: 21817   ROP Failure: 0x3F0
                                       Lid: 32758
                                       Lid: 16586   StoreEc: 0x3F0
                                       Lid: 22518
                                       Lid: 28874   StoreEc: 0x3F0
                                       Lid: 29516
                                       Lid: 31820   StoreEc: 0x3F0
FailureTimestamp                 : 02/02/2012 10:27:38
FailureContext                   : --------
                                   Operation: ISourceMailbox.EnumerateHierarchyChanges
                                   OperationSide: Source
                                   Primary (c0e7ee8d-6f43-430a-b11f-dfba42501ee6)
                                   Catchup: True


Attempt 9
Already getting desperate, decided to temporarily increase the maximum number of objects that can be handled by Outlook clients by setting both objtfolder and objtfolderview to a value greater than 500 (KB842022 or Maximum open folder objects per logon has been changed).

WARNING: this affects everyone on the mailbox server you set this and it also needs an IS restart so be very careful!!!

As I have a few servers that only host passive DBs, decided to implement the change in one of those servers (I set the registry key value to 3000) and switched over only that DB to that server.
Tried deleting the folders but was getting the same error regarding the 4,000 limit! Not sure why this time... Increased the registry key’s value to 6000 and decided to try again. However, although there were no errors at all on the server, no one could access any mailbox in that server!... Ups! Time to quickly rollback!
Another failed attempt...


Resolution
So how did I fix this problem? Since the beginning that I was thinking about what would happen if I tried to delete the last folder? Because I didn’t feel like expanding almost 3,000 folders (probably for Outlook to complain about the 500 limit!) this had to be done using a script.

Although I love writing scripts, I was avoiding doing this for some reason. But since everything else was failing, I decided to give it a go. And the result was that it worked without any problems!   :-D

I just wanted to quickly try this, so didn’t pay much attention to performance. For this reason, the script is not very efficient because:
it goes through all the folders one by one and then deletes the last one;
starts all over again, goes through all the folders one by one and then deletes the last one;
starts all over again....

In this case it took between 30 to 60 minutes to delete 2,890 folders but it eventually got there!   :)


WARNING: as with every script, make sure you test it properly before running it for a live user!!!


You can also find the script in the Microsoft TechNet Script Repository: Delete Outlook Folders Bottom-Up

# Script: DeleteFoldersBackwards.ps1
# Purpose: This scripts deletes every folder and subfolders for a specific top-folder starting from the last one
# Author: Nuno Mota
# Date:  Feb 2012

[String] $mbxName = "motan@parliament.uk"
[Int] $intCount = 0

[String] $dllPath = "E:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
[Void] [Reflection.Assembly]::LoadFile($dllPath)

$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
$Service.AutodiscoverUrl($mbxName, {$True})

# This is the root folder from where we want to start searching for the folder we want to delete.
# Once we find it, then we will go recursively down that folder.
# Other option would be to get the FolderID and start the search straight from there
$RootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox, $mbxName)
#$RootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root, $mbxName)
$RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service, $RootFolderID)

$FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
$FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
$Response = $RootFolder.FindFolders($FolderView)

# Go through all folders under the Inbox folder looking for the folder we want to delete
ForEach ($folder in $Response.Folders)
{
 # Check if the current folder is the folder we want to delete
 If ($folder.DisplayName -eq "Pictures of Y")
 {
  # Found the folder, so start a new Deep search across all its sub-folders
  $FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(3000)
  $FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
  $Response = $folder.FindFolders($FolderView)
  $RootFolder = $folder
  
  # Loop to go through all sub-folders while there are any
  While ($($Response.Folders).Count -gt 0)
  {
   # Get the last folder so we can then delete it (not very efficient...)
   ForEach ($folder in $Response.Folders)
   {
    #$folder.DisplayName
    $lastFolder = $folder
   }

   Write-Host "Deleting", $lastFolder.DisplayName
   $lastFolder.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
   $intCount++
   Write-Progress -Activity "Deleting Folders" -Status "Folders Deleted: $intCount"

   $Response = $RootFolder.FindFolders($FolderView)
  }

  # Delete the top folder and exit the first ForEach
  #Write-Host "Deleting Top ""$($RootFolder.DisplayName)"""
  $RootFolder.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
  Break
 }
}