The following Powershell script code can be useful if you want to distribute an Outlook folder link to your web-based central email archiving solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#----------------------------------------------------- function Release-Ref ($ref) { ([System.Runtime.InteropServices.Marshal]::ReleaseComObject( [System.__ComObject]$ref) -gt 0) [System.GC]::Collect() [System.GC]::WaitForPendingFinalizers() } #----------------------------------------------------- $olFolderInbox = 6 $newFolderName = "-> Mail Archive" #Optional: Check if user uses Outlook. Comment out if not necessary if (!(Test-Path $env:localappdata\Microsoft\Outlook\*.*st)) { Write-Host "outlook has not been started or configured on client yet"; exit } $o = new-object -comobject outlook.application $n = $o.GetNamespace("MAPI") #Root = Parent of Inbox $f = $n.GetDefaultFolder($olFolderInbox).Parent $exists = $f.Folders | where-object { $_.name -eq $newFolderName } if (!$exists) { $nf = $f.Folders.Add($newFolderName) $nf.WebViewURL = "http://mailarchive.mydomain.local" $nf.WebViewOn = "True" Write-Host "created" $a = Release-Ref($nf) } else { Write-Host "exists" } $a = Release-Ref($f) $a = Release-Ref($n) $a = Release-Ref($o) |
Run it e.g. via GPO as user-based startup Powershell script.
Worked perfectly. Thank you!
It worked for me!Thanx