Recipe 9.8. Mail-Enabling or Mail-Disabling a Public FolderProblemYou want to mail-enable or mail-disable a public folder. SolutionUsing a graphical user interface
If you want the public folder to be able to receive mail sent from the Internet directly to its SMTP address, you have some additional work to do:
Using VBScript' This code toggles the mail-enabled status of the selected folder. ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" ' e.g., "cyclone" strPubFolderPath = "<folderPath>" ' e.g., "/Some Folder/" ' ------ END CONFIGURATION --------- strE2K3WMIQuery = "winmgmts://" & strComputerName &_ "/root/MicrosoftExchangeV2" ' query for the specific folder we want Set wmiService = GetObject(strE2K3WMIQuery) query = "Select * From Exchange_PublicFolder" & " Where Path='" & _ strPubFolderPath & "'" Set targetFolder = wmiService.ExecQuery(query) ' report on the mail-enabled status, then toggle it For Each folder In targetFolder If folder.IsMailEnabled Then WScript.Echo folder.Name &_ " was mail-enabled as " & folder.TargetAddress & "; disabling it" folder.IsMailEnabled = false Else WScript.Echo folder.Name &_ " is not mail-enabled; enabling it" folder.IsMailEnabled = true End If Folder.Put_ Next WScript.Echo "Done processing folders." DiscussionWhen you mail-enable a public folder, users can send messages to it via SMTP in addition to posting messages to it. Mail-enabling a folder is a simple way to provide shared access to customer service questions, suggestions, or other material that comes from outside and needs to be accessible to multiple internal users. Toggling this state is simple in ESM or from a script; the one caveat is that you're not supposed to use WMI to mail-disable a public folder in a mixed-mode organization because Exchange 5.5 assumes that every public folder is always mail-enabled. Unfortunately, there's a bug in Exchange Server 2003 that allows you to do so, so your scripts should probably be careful enough to check. Whether you mail-enable a folder manually or via a script, its initial SMTP address will be the folder name with spaces removed (because spaces aren't valid in SMTP addresses). So "Junk Science" becomes junkscience@yourorg.com. You can add or remove this address, or other proxy addresses, using the E-mail Addresses tab of the folder properties dialog box. When you create a new mail-enabled folder, the Anonymous user token will automatically be granted Contributor permissions. This permission is required for SMTP mail sent from the Internet to be delivered to the folder. If you don't want inbound SMTP mail to be delivered, remove this permission. Using VBScriptThe script for this recipe uses a WMI query to locate the folder with the specified path; you can modify that path to select multiple folders if you prefer. For each folder returned by the query, the script toggles the IsMailEnabled property. This change isn't actually effective until the code uses the Put_ method to persist the change. See AlsoMS KB 824113 (You can use Windows Management Instrumentation to mail-disable a MAPI public folder in a mixed-mode Exchange organization) and MSDN: IsMailEnabled property of the Exchange_PublicFolder class |