Categories
Microsoft

Outlook Safe Mode Forced after KB3114409

This update, released 8th December 2015 caused safe mode to be forced for Outlook 2010.

No WSUS server so manual uninstall of the update can be achieved (at least on Windows 7 x64 Enterprise) via:

msiexec.exe /package {90140000-0011-0000-0000-0000000FF1CE} /uninstall {14CDCBF7-3CCC-42E2-A5BB-2D4926E16FAA} /norestart

ALWAYS check regedit for the {90140000-0011-0000-0000-0000000FF1CE} key first and examine the sub-key for KB3114409 to ensure this GUID is accurate!

Categories
Microsoft

Outlook : Recreate autocomplete stream data

  1. Import the FirstName, LastName and EmailAddress from all sent emails into individual contacts in the” Suggested Contacts” folder inside of the systems default Outlook profile via:

powershell script “import_sent_contacts_updated.ps1”

2. Export the “Suggested Contacts” folder from within the Outlook “Options > Advanced > Export” feature.  Filterout the fields so only Firstname, Lastname and EmailAddress are exported to an excel file

3. Delete the “Suggested Contacts” list from Outlook

4. Filter out the duplicates via “Filter > Advanced Filter > No Duplicates” from the excel file

5. Extract firstname from email address excel formula where C2 contains the email address:

=IF(ISNUMBER(SEARCH(“@”,LEFT(C2,FIND(“.”,C2)-1))), LEFT(LEFT(C2,FIND(“.”,C2)-1),FIND(“@”,LEFT(C2,FIND(“.”,C2)-1))-1), LEFT(C2,FIND(“.”,C2)-1))

 

Extract the lastname if format is first.last:

=IF(ISNUMBER(SEARCH(“.”,C3)), RIGHT(MID(C3,FIND(“.”,C3),FIND(“@”,C3)-FIND(“.”,C3)),LEN(MID(C3,FIND(“.”,C3),FIND(“@”,C3)-FIND(“.”,C3)))-1),C3)

6. Create a CSV from the excel file that has 3 columns (Type, Name, Email Address) where:

Type is “SMTP” or “EX” where SMTP=external addresses and EX=Exchange addresses

Name is “Firstname, Lastname”

EmailAddress is the email address

7. Close Outlook

8. Launch NK2Editor and open the steamautocomplete……dat file

9. Delete the contents

10. Action > Import from simple CSV > Select the formatted CSV file we created

11. Save

Categories
Microsoft

Outlook : Powershell : Import contacts from sent items

$outlook = new-object -com outlook.application
$olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$namespace = $outlook.GetNameSpace("MAPI")
$sentItems = $namespace.getDefaultFolder($olFolders::olFolderSentMail)
$alreadyAddedEmails = @() #Empty Array
$counter = 0;
$totalItems = $sentItems.items.count;
Write-Host "Scanning through" $totalItems "emails in SentItems"
$contacts = $outlook.Session.GetDefaultFolder($olFolders::olFolderSuggestedContacts)
##############################################################################################################
# FUNCTION - Adds Name/Email to SuggestedContacts - Unless it has already been added before (by this script).
##############################################################################################################
Function AddToSuggestedContactsIfNotAlreadyAdded ($name, $email)
{   
    if(($name -eq "") -or ($email -eq "") -or ($name -eq $null) -or ($email -eq $null)){
        return;
    }   
    if ($name -like '*@*') {
    $name = $null
    }
    else {
        $name = $name.Replace("'", "").Replace("""", "")
    }
    $contactAlreadyAdded = $false
    foreach ($elem in $global:alreadyAddedEmails) {
        if(($elem.ToLower() -eq $email.ToLower())){
            $contactAlreadyAdded = $true
        if ($name -eq $null) { $name = "** No Display Name **" }
            Write-Host  ($global:counter)"/"($totalItems)  "SKIPPED " $name.PadRight(25," ") "-" $email
            return;
        }
    }
    if(!$contactAlreadyAdded )    {
        $newcontact = $contacts.Items.Add()
        $newcontact.FullName = $name
        $newcontact.Email1Address = $email
        $newcontact.Save()
        $global:alreadyAddedEmails += $email
    if ($name -eq $null) { $name = "** No Display Name **" }
        Write-Host ($global:counter)"/"($totalItems)  "ADDED   " $name.PadRight(25," ") "-" $email
    }
}
# Loop through all emails in SentItems
$sentItems.Items | % {
    #Loop through each recipient
    $_.Recipients | %{
        AddToSuggestedContactsIfNotAlreadyAdded $_.Name $_.Address
    }
    $global:counter = $global:counter + 1
}
Categories
Microsoft

Outlook : Powershell : Clear Duplicate Contacts

#########################################################
# #
# Remove Duplicate Outlook Contacts by Jean Louw #
# Blog http://powershellneedfulthings.blogspot.com/ #
# #
#########################################################

$olSession = (New-Object -ComObject Outlook.Application).Session
$olSession.Logon(‘Outlook’) #Outlook is the profile name
$contactsFolder = 10
$tempFolderName = ‘temp_folder_’ + (get-date -Format ddmmyyyhhmmss)
$myContacts = $olSession.GetDefaultFolder($contactsFolder).Items
$tempFolder = $olSession.GetDefaultFolder($contactsFolder).Folders.Add($tempFolderName)

Write-Host “..getting unique items”
$uniqueContacts = $myContacts | Sort FullName -Unique

#move contacts to temp contacts folder
foreach ($Contact in $uniqueContacts) {
$Contact.Move($tempFolder) | foreach-object {Write-Progress “Backup unique items to temp folder…” $_.FullName; $_.FullName} | Out-Null
}

#read default contacts again and dump to csv
Write-Host “..export duplicates to csv”
$duplicates = $olSession.GetDefaultFolder($contactsFolder).Items
$duplicates | Export-Csv duplicates.csv

#delete all contacts left in default contacts folder
Foreach ($duplicate in $duplicates){
$duplicate.Delete() | foreach-object {Write-Progress “Deleting duplicate…” $_.FullName; $_.FullName} | Out-Null

Categories
Microsoft

Outlook Command Line Switches

Direct copy from http://www.outlook-tips.net/how-to/using-outlook-command-lines/

How to use Outlook’s Command line switches

When you’re having problems with Outlook you may be told to start Outlook using a specific command line switch.

To do this:

Close Outlook.

At the Start menu, Run command (or open the Run command by pressing Windows Key (windows key icon) + R type:

Outlook /switch

Then click OK to start Outlook. (There is a space between outlook and /.)

This screenshot shows how you enter it, using the /cleanreminders switch as an example.

command lines

Occasionally you’ll need to use the full path to Outlook, then the command line looks like this:

“C:Program FilesMicrosoft OfficeOffice11Outlook.exe” /switch

Notes:

Before using a command line switch, you need to close Outlook and verify it’s closed in Task Manager’s Processes tab.

Paths that include spaces between words must be enclosed in quotation marks (“) and are case sensitive.

If you use Vista or Windows 7, you can type the command line in the Start Search field on the Start menu.

You’ll need the full path if you  want to create desktop shortcuts using a switch, such as to open Outlook to a specific folder:

“C:Program FilesMicrosoft OfficeOffice11Outlook.exe” /select outlook:calendar

Frequently used Switches:

This group of switches are the most commonly used switches. (A complete list of switches is in the next section.)

/cleanreminders

Clears and regenerates reminders.

/cleanviews

Restores default views. Use with care as all custom views you created are lost.

/profile profilename

Loads the specified profile. If your profile name contains a space, enclose the profile name in quotation marks.

This switch is useful when there are multiple users of a Windows logon and each has their own Outlook profile.  Create desktop shortcuts to load a specific profile – use the following command line in the shortcut, replacing my name with your profile name:

“C:Program FilesMicrosoft OfficeOffice11Outlook.exe” /profile “Diane Poremsky”

/profiles

Opens the Choose Profile dialog box regardless of the Options setting on the Tools menu.

/resetnavpane

Outlook 2007 and 2010 only. Resets the navigation pane back to the default when Outlook starts.

/resettodobar

Outlook 2007 and 2010 only. Resets the to-do bar pane to the default settings when Outlook starts.

/safe

Starts Outlook without extensions, Reading Pane, or toolbar customization. Works with all versions.

Can also open Outlook in Safe mode by holding Ctrl key as you click on the Outlook icon

 

All Switches

/a

Creates an item with the specified file as an attachment.

Usage:

Outlook /a “C:My Documentslabels.doc”

If no item type is specified, IPM.Note form is assumed. This switch cannot be used with message classes that aren’t based on Outlook.

/altvba otmfilename

Opens the VBA program specified in otmfilename, rather than %appdata%MicrosoftOutlookVbaProject.OTM. Use this switch when you need to run macros not in your VBAProject file.

/autorun macroname

Opens Outlook and immediately runs the macro specified in macroname.

/c messageclass

Creates a new item of the specified message class, works for any valid MAPI form.

Examples:

  • /c ipm.activity creates a Journal entry
  • /c ipm.appointment creates an appointment
  • /c ipm.contact creates a contact
  • /c ipm.note creates an e-mail message
  • /c ipm.stickynote creates a note
  • /c ipm.task creates a task

/checkclient

Prompts for the default manager of e-mail, news, and contacts.

/cleanclientrules

Starts Outlook and deletes client-based rules. Used by non-Exchange account users.

/cleandmrecords

Deletes the logging records saved when a manager or a delegate declines a meeting. Used by Exchange Server accounts.

/cleanfinders

Removes Search Folders from the Microsoft Exchange server store.

/cleanfreebusy

Clears and regenerates free/busy information. This switch can only be used when you are able to connect to your Microsoft Exchange server.

/cleanprofile

Removes invalid profile keys and recreates default registry keys where applicable.

/cleanpst

Launches Outlook with a clean Personal Folders file (.pst)

/cleanreminders

Clears and regenerates reminders.

/cleanrules

Starts Outlook and deletes client- and server-based rules.

/cleanschedplus

Deletes all Schedule+ data (free/busy, permissions, and .cal file) from the server and enables the free/busy information from the Outlook Calendar to be used and viewed by all Schedule+ 1.0 users.

/cleanserverrules

Starts Outlook and deletes server-based rules. Used only with Exchange server accounts.

/cleansniff

Overrides the programmatic lockout that determines which of your computers (when running Outlook simultaneously) processes meeting items. The lockout process helps prevent duplicate reminder messages. This switch clears the lockout on the computer it is used, enabling Outlook to process meeting items.

/cleansubscriptions

Deletes the subscription messages and properties for subscription features. Used with SharePoint alerts.

/cleanviews

Restores default views. Use with care as all custom views you created are lost.

/designer

Starts Outlook without figuring out if Outlook should be the default client in the first run.

/embedding

Opens the specified message file (.msg) as an OLE embedding. Also used without command-line parameters for standard OLE co-create.

/explorer

Opens the new window in “explorer” mode (link bar on).

/f msgfilename

Opens the specified message file (.msg) or Microsoft Office saved search (.oss).

/firstrun

Starts Outlook as if it were run for the first time.

/folder

Opens a new window in “folder” mode (Navigation Pane off).

/hol holfilename

Opens the specified .hol file.

/ical icsfilename

Opens the specified .ics file.

/importprf prffilename

Launches Outlook and opens/imports the defined MAPI profile (*.prf). If Outlook is already open, queues the profile to be imported on the next clean launch.

/l olkfilename

Opens the specified .olk file.

/launchtraininghelp assetid

Opens a Help window with the Help topic specified in assetid.

/m emailname

Provides a way for the user to add an e-mail name to the item. Use either the full address or let alias resolve. Only works in conjunction with the /c command-line parameter.

Usage:

Outlook.exe /c ipm.note /m test@poremsky.com

Outlook.exe /c ipm.note /m dianep

/nocustomize

Starts Outlook without loading outcmd.dat (customized toolbars). With older versions of Outlook the *.fav file doesn’t load.

/noextensions

Starts Outlook with extensions turned off, but listed in the Add-In Manager.

/nopollmail

Starts Outlook without checking mail at startup.

/nopreview

Starts Outlook with the Reading Pane off and removes the option from the View menu.

/p msgfilename

Prints the specified message (.msg). Does not work with HTML.

/profile profilename

Loads the specified profile. If your profile name contains a space, enclose the profile name in quotation marks.

/profiles

Opens the Choose Profile dialog box regardless of the Options setting on the Tools menu.

/recycle

Starts Outlook using an existing Outlook window, if one exists. Can be used in combination with /explorer or /folder. The Outlook shortcut in the Quick Launch bar uses the /recycle switch.

/resetfoldernames

Resets default folder names (such as Inbox or Sent Items) to default names in the current Office user interface language.

For example, if you first connect to your mailbox Outlook using a Russian user interface, the Russian default folder names cannot be renamed. To change the default folder names to another language such as Japanese or English, you can use this switch to reset the default folder names after changing the user interface language or installing a different language version of Outlook.

/resetfolders

Restores missing folders for the default delivery location.

/resetnavpane

Clears and regenerates the Navigation Pane for the current profile. Removes all Shortcuts and Favorite Folders. Has the same effect as deleting profilename.xml in your user directory.

/rpcdiag

Opens Outlook and displays the remote procedure call (RPC) connection status dialog.

/s filename

Loads the specified shortcuts file (.fav). Use to load *.fav files created in older versions of Outlook.

/safe

Starts Outlook without extensions, Reading Pane, or toolbar customization.

/safe:1

Starts Outlook with the Reading Pane off. New to Outlook 2003.

/safe:2

Starts Outlook without checking mail at startup. New to Outlook 2003.

/safe:3

Starts Outlook with extensions turned off, but listed in the Add-In Manager. Outlook 2003 only.

/safe:4

Starts Outlook without loading Outcmd.dat (customized toolbars) and *.fav file. Outlook 2003 only.

/select foldername

Starts Outlook and opens the specified folder in a new window.

Usage:

“C:Program FilesMicrosoft OfficeOffice11Outlook.exe” /select outlook:calendar

outlook /select “outlook:InboxOld Messages”

/sniff

Starts Outlook and forces a detection of new meeting requests in the Inbox, and then adds them to the calendar.

/t oftfilename

Opens the specified .oft file.

/v vcffilename

Opens the specified .vcf file.

/vcal vcsfilename

Opens the specified .vcs file.

/x xnkfilename

Opens the specified .xnk file.

Categories
Microsoft Software

Outlook: Export all mail into Explorer

This guide uses a VB script copied from https://techniclee.wordpress.com/2013/05/09/export-outlook-folders-to-the-file-system/ as it’s basis.

The script here only copies emails from Outlook with no option for deleting the emails, for another layer of safety the deletion is left to the user to complete manually.

The script will copy all emails from a selected folder, including subfolders, into Windows and retain each email’s attachments, sender and recipient addresses along with the timestamp information relating to the email (not the creation date within Windows).

I’ve copied the edited script below for reference, thanks to the Keble IT Manager and a few of my own edits too I have a slightly improved version which handles errors better, this is available at the end of this article.

The process for importing this script to users is manual, thankfully only a handful of people require it so it’s not a huge overhead. The deployment process is:

From within Outlook:

  1. Click [File] > [Options] > [Customize Ribbon] and [TICK] the [Developer Ribbon] check box, click [OK] to all open menus to close them
  2. Click the [Developer] ribbon menu item > [Visual Basic]
  3. [Insert] > [Module]
  4. Copy and paste the script below into the window
  5. Click the [Save] button and close the [Visual Basic Window] to return to Outlook
  6. Click [File] > [Options] > [Customize Ribbon]
  7. [UN-TICK] the [Developer Ribbon]
  8. Click the [New Tab] button, highlight the [New Tab (Custom)] entry in the [Main Tabs] list > click the [Rename] button > Name the tab “Email Export”, click [OK] to save
  9. Highlight the [New Group (Custom)] entry in the [Main Tabs] list >  click the [Rename] button >Name the group “Export Highlighted Folder to Windows” > Select an appropriate icon
  10. In the left column, from the [Choose commands from:] drop-down menu select [Macros]
  11. Click and drag the [Project1.CopyOutlookFoldertoFileSystem] entry onto the newly created new group named “Export Highlighted Folder to Windows”
  12. Highlight the [Project1.CopyOutlookFoldertoFileSystem] entry in the [Main Tabs] list >  click the [Rename] button >Name the command “Export”.
  13. Click [OK] to close all open menus and return to Outlook

This creates a new tab with the script loaded into a single command named “Export” on the Outlook ribbon. The script doesn’t *ever* delete mail from Outlook, it only ever copies. To use the script:

  1. Highlight a folder on the Outlook navigation pane that you want to copy to Windows
  2. Click the new “Export” button
  3. Select the Windows folder you want to export to
  4. Click [OK] and wait for the export to complete, it may take a few minutes for 1GB+ folders
  5. Once the transfer window disappears the copy is complete, inspect the folder in Windows to ensure the emails are there
  6. Having double checked the export worked you can down delete the source folder from Outlook or all the emails inside it.

 

'On the next line edit the starting folder as desired. If you leave it blank, then the starting folder will be the local computer.
Const STARTING_FOLDER = ""
 
Dim objFSO As Object
 
Sub CopyOutlookFolderToFileSystem()
 ExportController "Copy"
End Sub
 
'Sub MoveOutlookFolderToFileSystem()
' ExportController "Move"
'End Sub
 
Sub ExportController(strAction As String)
 Dim olkFld As Outlook.MAPIFolder, strPath As String, dest As String
 strPath = SelectFolder(STARTING_FOLDER)
 If strPath = "" Then
 MsgBox "You did not select a folder. Export cancelled.", vbInformation + vbOKOnly, "Export Outlook Folder"
 Else
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set olkFld = Application.ActiveExplorer.CurrentFolder
 ExportOutlookFolder olkFld, strPath
 If LCase(strAction) = "move" Then
 olkFld.Delete
 Else
 dest = strPath & "\" & olkFld.Name
 MsgBox "Now check that the right number of messages and folders are in " & dest & ", then delete the folder from Outlook"
 End If
 End If
 Set olkFld = Nothing
 Set objFSO = Nothing
End Sub
 
Sub ExportOutlookFolder(ByVal olkFld As Outlook.MAPIFolder, strStartingPath As String)
 Dim olkSub As Outlook.MAPIFolder, olkItm As Object, strPath As String, strMyPath As String, strSubject As String, intCount As Integer, s As String, d As Date, f As String, itemlist As Outlook.items
 
 On Error Resume Next
 ' Set an initial date just in case first item is broken
 d = Date
 strPath = strStartingPath & "\" & olkFld.Name
 objFSO.CreateFolder strPath
 ' Folder exists
 If Err.Number = 58 Then
 Dim rc As Integer
 rc = MsgBox("The folder " & strPath & " already exists, proceed anyway?", vbOKCancel)
 If rc = 1 Then
 Err.Clear
 Else
 Exit Sub
 End If
 End If
 
 Set itemlist = olkFld.items
 itemlist.Sort "[SentOn]", False
 
 For Each olkItm In itemlist
 ' Start with clean slate
 Err.Clear
 s = RemoveIllegalCharacters(olkItm.Subject)
 If Err.Number <> 0 Then
 s = "[Error in subject]"
 Err.Clear
 End If
 
 f = RemoveIllegalCharacters(olkItm.SenderName)
 If Err.Number <> 0 Then
 f = "[Error in sender]"
 Err.Clear
 End If
 ' This may fail in very rare circumstances. It'll use the date of the previous item as we've not reset it. That's probably close enough as the items are sorted into ascending date order.
 d = olkItm.SentOn
 
 strSubject = "[From] " & f & " [Subject] " & s
 strFilename = strSubject & ".msg"
 intCount = 0
 Do While True
 strMyPath = strPath & "\" & strFilename
 If objFSO.FileExists(strMyPath) Then
 intCount = intCount + 1
 strFilename = strSubject & " (" & intCount & ").msg"
 Else
 Exit Do
 End If
 Loop
 olkItm.SaveAs strMyPath, olMSG
 ChangeTimeStamp strMyPath, d
 Next
 For Each olkSub In olkFld.Folders
 ExportOutlookFolder olkSub, strPath
 Next
 Set olkFld = Nothing
 Set olkItm = Nothing
End Sub
 
Function SelectFolder(varStartingFolder As Variant) As String
 ' This function is a modified version of the SelectFolder function written by Rob van der Woude (http://www.robvanderwoude.com/vbstech_ui_selectfolder.php)
 
 ' Standard housekeeping
 Dim objFolder As Object, objShell As Object
 
 ' Custom error handling
 On Error Resume Next
 
 ' Create a dialog object
 Set objShell = CreateObject("Shell.Application")
 Set objFolder = objShell.BrowseForFolder(0, "Select the folder you want to export to", 0, varStartingFolder)
 
 ' Return the path of the selected folder
 If TypeName(objFolder) <> "Nothing" Then SelectFolder = objFolder.self.Path
 
 ' Standard housekeeping
 Set objFolder = Nothing
 Set objShell = Nothing
 On Error GoTo 0
End Function
 
Function RemoveIllegalCharacters(strValue As String) As String
 ' Purpose: Remove characters that cannot be in a filename from a string.'
 ' Written: 4/24/2009'
 ' Author: BlueDevilFan'
 ' Outlook: All versions'
 RemoveIllegalCharacters = strValue
 ' RemoveIllegalCharacters = LCase(RemoveIllegalCharacters)
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "<", "(")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, ">", ")")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, ":", "-")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, Chr(34), "'")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "/", "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "\", "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "|", "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "?", "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "*", "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "+", "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "@", "_at_")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, Chr(9), "")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "û", "u")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "ü", "u")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "à", "a")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "ç", "c")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "é", "e")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "è", "e")
 RemoveIllegalCharacters = Replace(RemoveIllegalCharacters, "ê", "e")
End Function
 
Sub ChangeTimeStamp(strFile As String, datStamp As Date)
 Dim objShell As Object, objFolder As Object, objFolderItem As Object, varPath As Variant, varName As Variant
 varName = Mid(strFile, InStrRev(strFile, "\") + 1)
 varPath = Mid(strFile, 1, InStrRev(strFile, "\"))
 Set objShell = CreateObject("Shell.Application")
 Set objFolder = objShell.NameSpace(varPath)
 Set objFolderItem = objFolder.ParseName(varName)
 objFolderItem.ModifyDate = CStr(datStamp)
 Set objShell = Nothing
 Set objFolder = Nothing
 Set objFolderItem = Nothing
End Sub