NK2Edit

NK2Edit v1.21
Copyright (c) 2010 Nir Sofer
Web site: http://www.nirsoft.net/utils/outlook_nk2_edit.html

Introduction

Every time that you type an email address or name in the message window of MS-Outlook, it automatically offer you a list of users and email address that you can choose. This feature is known as 'AutoComplete' and Outlook automatically build this emails list according to user activity and save it into a file with .NK2 extension.

In some circumstances, you may need to repair or modify the values appeared in the AutoComplete list, or you may want to remove unwanted email addresses and/or to add new email addresses. MS-Outlook doesn't provide any ability to edit this AutoComplete list, so this is where NK2Edit software can help you.

NK2Edit Features

  • Easily modify or fix all information stored in the NK2 file, including the display name, the email address, the exchange string, the Drop-Down display name, and the search string.
  • Easily remove unwanted single quote characters from the display name and from the Drop-Down list.
  • Delete unwanted emails, as well as add new emails, by typing them manually, or by choosing them from the address book of Outlook.
  • Copy NK2 records from one NK2 file to another - simply by copy and paste !
  • Build a completely new NK2 file and add the desired emails into it, by typing them manually, by adding them from your address book, or by copying records from another NK2 file.
  • Extract data from corrupted NK2 files that Outlook cannot read anymore (When Outlook AutoComplete stopped working) and even repair them so Outlook will be able to read them again.
  • Export all data stored in the NK2 file into a special Unicode text file in a stucture similar to .ini file of Windows. You can open it any text editor you like, make the changes you need, and then convert it back into NK2 file that Outlook can use.
  • Export the emails information stored inside NK2 file into HTML/Text/csv/xml file.
  • Copy the selected NK2 records in tab-delimited format and then paste the information into Excel.
  • Change the order of the records in the NK2 file, which also affects the order they appear in the drop-down. You can also sort the list in alphabetical order of the Drop-Down display names. (However, be aware that Outlook change the order again when the user send emails)
  • Command-Line Support: Write simple scripts that can add, remove, or modify records inside the NK2 file, without displaying any user interface.
  • NK2Edit is a portable application that can be used from any computer with Windows operating system (Starting from Windows 2000) without need of any installation process, and without making changes in the Registry.
  • NK2 Control Center - Allows you to watch to location and the status of all NK2 files in your organization.

System Requirements

  • NK2Edit works on any version of Windows, starting from Windows 2000 and up to Windows 7/2008. NK2Edit is a Unicode based application, and thus it cannot work under Windows 95/98/ME.
  • NK2Edit can read, write, and create NK2 files for Outlook 2003, Outlook 2007, and Outlook 2010 Beta.
  • Outlook installation is not required on the computer that you run NK2Edit, except of "Add Records From Address Book" feature, which cannot work without Outlook. NK2Edit can also be used to open, edit, and save NK2 files on remote computers in your network, as long as you have read/write permission to the remote NK2 file.

License

The license for using NK2Edit is different from most of other NirSoft utilities:
  • NK2Edit is completely free for personal use at your home and for using in any charity/non-profit organization.
  • If you need to use NK2Edit in a company/business organization, you can freely try and evaluate the NK2Edit software for 14 days and verify that the software really works as you expect.
  • If after the 14-days of evaluation you decide to continue using it, you have to purchase a
  • commercial license according to the number of workstations with Outlook that NK2Edit is needed for opening or editing their NK2 file.
    For more information about commercial licenses, click here
  • If you or your company already sent a donation to support NirSoft in the past, the company deserve to receive a commercial license for no additional fee. In this case, you should send a note to nk2edit@nirsoft.net and specify the PayPal account that was used to send the money.

Disclaimer

The software is provided "AS IS" without any warranty, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The author will not be liable for any special, incidental, consequential or indirect damages due to loss of data or any other reason.

NK2Edit vs NK2View

NK2View was originally released as a small free tool for viewing the content of NK2 files. After many requests from users, I added some limited editing features that allowed the users to remove and add records into the NK2 file. However, NK2View was not designed to be a real NK2 editor, and for some NK2 files, it failed to add/remove records properly.

As opposed to NK2View, NK2Edit was designed as a real NK2 editor that can make any change you need and then save it back into a valid NK2 file.

Using NK2Edit Without Installation

NK2Edit can be used without any installation process. Simply download the zip file of NK2Edit, extract the files into any folder you like, and run the executable file (NK2Edit.exe) . You can also put the files of NK2Edit in a shared network drive, and run it from any workstation in your company.
Whenever you want to remove NK2Edit from your system, simply delete the files of NK2Edit (NK2Edit.exe, NK2Edit.cfg, and NK2Edit.chm). NK2Edit doesn't write anything to the Registry or other places, so deleting the files is enough for removing NK2Edit completely from your system.

Using NK2Edit With Install/Uninstall Support

If you want, you can also download NK2Edit with installer (NK2Edit_setup.exe), and install NK2Edit like any other software. The installer of NK2Edit automatically add a new group to the start menu of Windows and it also add a new entry to the uninstall list of Windows, so you'll be able to easily uninstall NK2Edit if it's needed.

x64 Version of NK2Edit

NK2Edit has 2 features that extract address book/mailbox information directly from Microsoft Outlook: "Add New Records From Address Book" and "Add Records From Mailbox Recipients".

If you use the 64-bit version of Microsoft Outlook 2010, you must download and use the x64 of NK2Edit in order to use the above 2 features. In all other cases, you should use the 32-bit version of NK2Edit. Be aware that if you have 64-bit Windows installation, but the installation of MS-Outlook is 32-bit, you must use the 32-bit version of NK2Edit in order to use the above 2 features.

Before You Start

  • When you edit your NK2 file, remember to verify that the executable of Outlook (Outlook.exe) is not running. If you edit the NK2 file when Outlook is opened, Outlook may save the NK2 file and overwrite your changes.
  • Backups of NK2 file: When you make changes in your NK2 files, it's always important to keep a backup of the original NK2 file, so if something goes wrong and the modified NK2 doesn't work properly, you'll be able to restore the original one.
    When you save your NK2 changes in the first time, NK2Edit automatically creates a backup of the original NK2 file with NK2Edit.First.bak extension. To restore the original NK2 file, simply use the 'Restore Backup From First Save' option. You can disable the automatic backup by unchecking the 'Automatically Backup On First Save' in the Options, although it's recommended to keep this options enabled.
    In addition to the automatic backup of the first save, NK2Edit also allows you to create a backup when you think it's important. Simply use the 'Backup Current NK2 File' option, and NK2Edit will create a backup file with .NK2Edit.bak extension.
  • Know the limitation for number of records in NK2 files: Outlook 2003 limits the maximum number of records in NK2 files to 1000, while Outlook 2007/2010 limits the maximum number of records to 2000. When you edit your NK2 files, you should keep the number of records below these limits.
  • In Outlook 2010 (Currently in Beta), the AutoComplete file is saved with .dat extension and its header data is a little different from the previous versions of Outlook. In order to save the AutoComplete file for Outlook 2010 properly, you have to save the file with .dat extension, so NK2Edit will save it with the new file header of Outlook 2010.

Versions History

  • Version 1.21
    • Fixed a crash problem in some command-line options.
  • Version 1.20
    • Added NK2 Control Center window, which allows to watch the status, the location, and general statistics of all NK2 files on your organization. This feature requires to add a single line into the logon script to collect the NK2 information.
  • Version 1.13
    • Added /generate_new_nk2 command-line option, which generates a completely new NK2 file from the email addresses stored in the Outlook mailbox.
  • Version 1.12
    • Added 'Remove Double Quotes From All Display Names' option.
    • Added RemoveDoubleQuotes command to NK2Edit scripts.
  • Version 1.11
    • When specifying empty string ("") in the export command-line options (/stab, /scomma, and so on) the data is now sent to the standard output.
    • Fixed some focus and tab order issues.
  • Version 1.10
    • Added 'Replace' option - Find and replace strings in all records of the NK2 file.
    • Added 'Replace' and 'ReplaceField' script actions - for replacing strings inside the NK2 file by using automatic scripts.
  • Version 1.07
    • Added 'Sort Items By Weight Values' option.
    • Added /copy_default to copy the nk2 file of the default Outlook profile into the specified location. You can use this command-line option in the logon script of every user to create a backup of all NK2 files on the server (For licensed version only)
    • Added /merge_files to merge 2 nk2 files from command-line. (For licensed version only)
  • Version 1.06
    • Fix bug: "The profile name is not valid" error message displayed when using 'Add Records From Mailbox Recipients' and 'Add Records From Address Book' options with Outlook 2010.
  • Version 1.05
    • Added 'Add Records From Mailbox Recipients', which allows you to scan your mailbox, collect email addresses, and merge them into your NK2 file.
  • Version 1.00: First release.

Getting Started With NK2Edit

When you run NK2Edit, it automatically detect the .NK2 file of your default Outlook profile, and open it. If you want to open any other NK2 file, simply go to File->Open .NK2 File (Or press Ctrl+O) and choose the desired NK2 to open.

NK2Edit can work in 2 edit modes:

  • Table Edit Mode: This is the default edit mode, and you should use this mode most of the time. The NK2 records are displayed in simple table. You can double-click a single record to edit the record data. You can also select one or more records, and then delete them, move their location up or download, or copy them and then paste them into another NK2 file.
    In this mode, you can also add new NK2 records by using 'Add New Record' or 'Add New Records From Address Book'.
  • Raw Text Edit Mode: This mode should only be used by advanced users. In this mode, you get a text editor like Notepad, and the NK2 records are provided in stucture similar to ini files of Windows. You can also copy the entire text into another text editor that you like, make your changes, and then paste the text back to NK2Edit editor.
The changes you make in both edit modes won't affect the actual NK2 file until you use the 'Save Current NK2 File' option (Ctrl+S). Only when you use the save option, all your changes will be saved into the NK2 file. You can also use the 'Save As' option if you want to save your changes into a new NK2 instead of overwriting the existing one.
As already mentioned, when you overwrite your NK2 file in the first time, NK2Edit automatically creates a backup copy of the original NK2 file with .NK2Edit.First.bak extension.

More Topics...

  • How to purchase commercial license.
  • Columns Description of NK2Edit Table Mode
  • NK2Edit Menus Description
  • How to edit NK2 record
  • How to find and replace strings in the NK2 file.
  • How to merge 2 or more NK2 files.
  • How to recover and repair corrupted NK2 files.
  • The Raw Text Edit Mode.
  • NK2Edit command-line options
  • NK2Edit Scripts - Edit NK2 files from command-line.
  • The location of the NK2 file of Outlook.
  • NK2 Control Center

Support For NK2Edit

If you think that you found a bug in NK2Edit, or you want to request an improvement for future versions, or you have a question about using NK2Edit, you are welcomed to send a message to nk2edit@nirsoft.net
If you already purchased a commercial license, please specify the invoice ID or the registration code inside the message.


Columns Description of NK2Edit Table Mode

  • Index: The position of the record inside the NK2 file. The position of the records also affects the order that the emails are displayed in the drop-down of Outlook. When you click the Index column header, and the table is sorted by the index value, NK2Edit also allows you to move the position of the records up and down (Ctrl+F7 and Ctrl+F8). However, you should be aware that when the user sends a message, the destination email is automatically moved to the first position in the NK2 file.
  • Address Type: Contains the type of the email address: SMTP for regular email addresses, EX for MS-Exchange addresses or FAX for Fax addresses.
  • Display Name: The full name of the user, which is also displayed when an item is chosen from the AutoComplete drop-down. When the name of the user is not available, Outlook put the email address in this field.
    NK2Edit allows you to modify the 'Display Name' by using the 'Edit Selected Record' option (F9).
  • Email/Exchange String: When the address type is 'SMTP', this column contains the email address. When the address type is 'EX' (Exchange), this column contains the exchange address which looks like '/o=First Organization/ou=first administrative group/cn=Recipients/cn=UserName'.
    NK2Edit allows you to modify this field by using the 'Edit Selected Record' option (F9).
  • Drop-Down Name: The name that appears in the drop-down of Outlook AutoComplete. Outlook automatically set this value in a format of 'Display Name <Email Address>'.
    NK2Edit allows you to modify this field by using the 'Edit Selected Record' option (F9), but when the user send an email, Outlook automatically set this value in 'Display Name <Email Address>' format.
  • Search String: When the user type the first letters in the address text-box of Outlook, the 'Search String' value is used to locate the right emails to put in the AutoComplete drop-down. For example, if you have NK2 record with 'abcd' as the search string value, and the user type 'abcd' in the address text-box of Outlook, this NK2 record will appear in the drop-down.
    NK2Edit allows you to modify this field by using the 'Edit Selected Record' option (F9), but when the user send an email, Outlook automatically set this value to the email address or to the MS-Exchange name.
  • Domain: The domain of the SMTP email address. This column allows you to easily sort the records list by the domain of the email address. (Simply click the column header)
  • SMTP Address: Relevant only for Exchange records (Address Type=Ex). Displays the SMTP address of the Exchange account, only if it's stored inside the NK2 record.
  • Display Type: For most NK2 records, this column contains the value of 'Mail User', which is a regular mail account (SMTP or Exchange). For NK2 records which contains a distribution list, this column contains the value of 'Distribution List' or 'Private Distribution List'.
  • Record Weight: Weight value of the record. Records with higher weight values get a better position in the NK2 file when the a message is sent to the email address of the record. Outlook automatically update the weight value according to the popularity of the email address. (Email address that the user send more messages, get higher value)
    Also, Outlook sorts the records in the NK2 file according to this Weight value. The first record (with index no. 1) have the largest Weight value, while the last records have the lowest Weight values (usually 1).
To easily understand the meaning of the columns, here's a small image that can help you:
  • Display Name: Marked in the image with blue color.
  • Email/Exchange String: Marked in the image with red color.
  • Drop-Down Name: Marked in the image with green color.

Return to NK2Edit introduction page


NK2Edit Menus Description

  • File
    • Open .NK2 File: Select the NK2 file to open for editing.
    • New .NK2 File Start a newly empty NK2 file. You can add new records to the new file by using 'Add New Record' or 'Add Records From Address Book' options, or by Copy and Paste from another NK2 file.
    • Backup Current NK2 File: Backup the NK2 that is currently opened. The backup file is saved with the same NK2 filename, but with .NK2Edit.bak extension. For example, if the NK2 filename is Outlook1.NK2, the created backup filename will be 'Outlook1.NK2.NK2Edit.bak'.
    • Restore Last NK2 Backup: Restore from the last backup that was previously created with 'Backup Current NK2 File' option.
    • Restore Backup From First Save: Restore from the backup that was created in the first time that you used NK2Edit with the current NK2 file. Be aware that if you use NK2Edit for long time, this backup might be quite old.
    • Save Current NK2 File: Save and overwrite the existing NK2 file. You should use this option after you made all the changes you need and you want to save them into your NK2 file.
    • Save As Save into another NK2 file instead of the one that you originally opened.
    • Open Default NK2 Folder: Simply open in Explorer the default folder that Outlook uses to save the .NK2 files.
    • Export Selected Items: Allows you to export the selected NK2 records into text files, html files, xml files, and csv files. Be aware that the files created with this export option cannot be converted back into NK2 file.
  • Action
    • Edit Selected Record: Simply edit the selected record. When you choose this option, a new dialog-boxed with the selected record is opened, and allows you to modify the values of this record.
    • Add New Record: Add new record according to the display name and email/exchange string that you specify. The search string and drop-down name are automatically filled for you.
    • Add New Records From Address Book: Allows you to add multiple emails from the address book into your NK2 file. This option works only if Outlook is installed properly on your computer.
    • Add Records From Mailbox Recipients: This option allows you to scan your Outlook mailbox, collect the email addresses of all recipients that you sent/recieved messages in the last xx days, and then merge them into the NK2 file, according to the current merge mode. The email addresses are sorted according to the sent/received time of the message, so the recipients that you sent them messages recently will be added in a better position.
      By default, NK2Edit only scans and adds the email addresses from the messages that you sent. You can also choose to grab email addresses from the received messages, but using this option may also add email addresses of spam/junk messages into your NK2 file.
    • Delete Selected Records: Simply delete the selected NK2 records.
    • Move Selected Records Up:
    • Move Selected Records Down: This option only works when the NK2 list is sorted by the index value (You have to click on the 'Index' column header). It moves the selected records up/down to change their position inside the NK2 file. You can use this option to set the order that the NK2 records are displayed in the Drop-Down of Outlook. However, when you send a message from Outlook, Outlook automatically move the sent email to a new position, so the order you set with these options won't persist for long.

      Notice: When you change the order of the NK2 records, it's recommended to set the weight values according to the new records order. You can do it in 2 ways: by reseting all Weight values to 1 (see below) or by using the 'Set All Weight Values By Records Index' option.

    • Sort Index By Drop-Down Name: Sort the NK2 records so they'll appear in alphabetical order inside the drop-down of Outlook. However, be aware that when the user send messages with Outlook, Outlook automatically put the destination email in the top of the NK2 records, and thus sorting the records with this option won't persist for long time.
      Also, if you choose to use this option, it's also recommended to set the weight values according to the new records order. (See the remark for Move Selected Records Up/Down)
    • Sort Items By Weight Values: Sort the NK2 records according to their Weight values. It's recommended to use this option after merging multiple NK2 files into one.
    • Reset All Weight Values to 1: Simply set the weight value of all records to initial '1' value.
    • Set All Weight Values By Records Index: Set the weight value of all records according to the current records index/order. This option can be used after sorting the records with the other options ( 'Move Selected Records Up', 'Move Selected Records Down', and 'Sort Index By Drop-Down Name'), so the weight values of all records will match the records order.
    • Remove Quotes From All Display Names: Sometimes Outlook add unwanted single-quote characters into the display names of the NK2 file. This option allows you to easily remove the unwanted single-quote characters from all records in the currently opened .NK2 file.
  • Edit
    • Find and Find Next: Simply find the desired record according to the text you type. Works on both edit modes.
    • Replace Find and replace strings for selected records or for all records in the NK2 file.
    • Remove Find/Replace Marks Remove the yellow marks of the last Find/Replace activity.
    • Copy: Copy the selected NK2 records to the clipboard. You can use it with combination of 'Paste' menu item to copy NK2 records from one file to another.
    • Copy As Tab Delimited: Copy the selected NK2 records to the clipboard in tab-delimited format. You can use this copy option to paste the NK2 records information into Excel, but you cannot use it to copy records from one .NK2 file to another.
    • Paste: Simply paste the records you previously copied.
  • Options
    • Raw Text Edit Mode: Special mode for advanced users that shows the content of the NK2 file in readable text format that looks like the .ini file of Windows.
    • Table Edit Mode: The default mode that shows all NK2 in a table.
    • Merge Mode:
      Determines how Nk2Edit should behave when you try to add an email that already exists in the NK2 records:
      • Always Add New Records: If this option is selected, new emails are always added, even if they already exist, which means that duplicate records might be created.
      • If Email Exists - Overwrite: If this option is selected, and you try to add a new record with email that already exists, your new record will overwrite the existing record with the same email.
      • If Email Exists - Don't Add: If this option is selected, and you try to add a new record with email that already exists, your new record will be discarded.
      The Merge Mode affects the following actions: Copy/Paste, 'Add New Record', and 'Add Records From Address Book'.
    • Automatically Backup On First Save: If this option is selected, NK2Edit automatically creates a backup when you overwrite existing NK2 in the first time.
    • Overwrite Question Before Every Save: If this option is selected, NK2Edit ask you whether you want to overwrite the existing file before any save. If this question is annoying for you, you can turn it off.
    • Ask Before Any Delete: If this option is selected, NK2Edit ask you whether you want to delete records. If this question is annoying for you, you can turn it off.
    • Ask Before Discard Changes: If this option is selected, and you try to exit or open another NK2 file after you made some changes in the current file, NK2Edit will ask you whether you want to discard the changes.


How to edit existing NK2 record

If you want to edit an existing record, simply select the desired record in the table edit mode, and then double-click with the mouse or press F9. The edit record window will be opened.

The most important fields for editing are the 'Email/Exchange' and 'Display Name'. If the address type is EX (Microsoft Exchange), the 'Email/Exchange' field contains an Exchange address like /o=First Organization/ou=first administrative group/cn=Recipients/cn=Nirs
If the address type is SMTP, the 'Email/Exchange' field contains the email address, like nirsofer@yahoo.com
The 'Display Name' field is simply the name of the recipient, like 'Nir Sofer'.

The 'Drop-Down Name' and 'Search Strings' fields are usually filled automatically by Outlook according to the values in 'Email/Exchange' and 'Display Name' fields. NK2Edit allows you to put any string you like in these fields, but you should be aware that when the user sends an email to this recipient, Outlook automatically reset these fields to the default. If you want to put the defaults of Outlook into The 'Drop-Down Name' and 'Search Strings' fields, simply click the AutoFill button.

The 'Display Type' should be 'Mail User' for most of the NK2 records. For MS-Exchange addresses: if the EX address is a distribution list or a remote user, the appropriate 'Display Type' should be selected.


How to find and replace strings in the NK2 file

NK2Edit allows you to easily find and replace strings in all records of your NK2 file. You can use it, for example, to fix incorrect domain name or incorrect Exchange strings that appear in the NK2 file more than once.
In order to use the 'Replace' option, simply go to Edit->Replace or press Ctrl+P.

In the 'Find/Replace' window, you should fill the string that you want to find, and the new string that you want to place instead of the old one. In the above example, I chose to replace the '@nirsoft.net' domain string to 'softnir.net'.

You can also choose which fields in the NK2 records will be affected by the 'Find/Replace' operation. However, it's recommended to allow NK2Edit to automatically update the Drop-Down Name and the Search String according to the other fields.

After you click the 'Replace All' button, NK2Edit find and replace the strings according to your replace settings, and then displays all modified records in yellow mark, so you can verify that the find/replace operation worked properly.

You can also make an automatic find and replace from a script, without displaying any user interface. For more information: NK2Edit Scripts - Edit NK2 files from command-line.


How to merge 2 or more NK2 files

  1. Run 2 or more instances of NK2Edit, according to the number of NK2 files that you want to merge. In every window of NK2Edit, open the desired NK2 file.
  2. Optionally, you can also run another instance NK2Edit, create a newly empty NK2 file (Ctrl+N), and then merge the other NK2 files into the new one.
  3. In the NK2Edit window containing the source NK2 file, select the records that you want to merge or press Ctrl+A to select all the records. After that, press Ctrl+C to copy the records into the clipboard.
  4. In the NK2Edit window containing the destination NK2 file (it might be an existing NK2 file or a newly empty one), Go to Options->Merge Mode, and choose the desired mode for merging.
  5. Press Ctrl+V (Paste) to add the records that you copied from the other NK2 file.
  6. You can continue to copy and paste more records from other NK2 files.
  7. When you finish to copy all the NK2 records you need, it's recommended to use the 'Sort Items By Weight Values' option (under the Action Menu), so the records will be sorted properly according to the Weight values of the merged records.
  8. Finally, press Ctrl+S to save your changes into the NK2 file.


How to recover and fix corrupted NK2 files

How to recover and fix corrupted NK2 files with NK2Edit

If you have any corrupted NK2 file that Outlook cannot read and the AutoComplete feature doesn't work properly, you can try to open and fix the NK2 by following the instructions below:
  1. Go to File->Open .NK2 File (Ctrl+O) and choose the corrupted NK2 file.
  2. NK2Edit will open the NK2 file and will display all the records found in it. It might also display a warning message about a problem found in the file.
  3. Backup this NK2 file (it's very important !) by using the internal backup of NK2Edit (Ctrl+B) or by manually copying the NK2 into another location.
  4. Browse through all records (in Table Edit Mode) and check if there any record with unusual characters or empty fields. If you found unusual records, simply delete them.
  5. Press Ctrl+S to save the file, and then open Outlook to check whether it can read the NK2 file properly.
  6. If Outlook still cannot read the NK2 file properly, you can try to switch into 'Raw Text Edit Mode', and then locate records with unusual fields that cannot be found with the Table Edit Mode.

There is also another alternative to recover your NK2 file: instead of fixing the previous NK2 file, you can create a new nk2 file, and add the desired email addresses by using 'Add Records From Mailbox Recipients' option. This option automatically scans your mailbox, collect all email addresses that you recently used, and add them into the NK2 file.


The Raw Text Edit Mode

NK2Edit provides a special edit mode that allows you to view and edit the records of NK2 file as a text file that looks like the .ini files of Windows. Every record begins with [record] header, followed by a sequence of lines with 'Property Number=Value' structure. The property number is written as 32-bit hexadecimal number, and the Value is written as string, number or Hex-Dump sequence, depending on the type of the property.

Here's the list of all major properties that you can find in the Raw Text Edit Mode:

Property ID | Type | Name | Description
6001001f | String | Search String | Outlook uses this string for searching the right recipient when the user type the letters in the To/CC text-box. For example, if the value in this field is abcd, and the user type abcd in the recipients text box, this record will be displayed in the drop down. However, you should be aware that Outlook automatically put the email address in this field when the user sends a message.
0c150003 | Integer | Recipient Type | The type of the recipient. 1 = To, 2 = CC, 3 = BCC.
0fff0102 | Binary | EntryID | Unique EntryID of this recipient, in binary format. Generally, you should not modify this value. NK2Edit automatically generate this ID according to the other fields.
300b0102 | Binary | Search Key | Contains a unique search key of this recipient, in binary format. Generally, you should not modify this value. NK2Edit automatically generate this key according to the other fields.
0ffe0003 | Integer | Object Type | The type of the recipient object. 6 = Individual Recipient, 8 = Distribution List Recipient.
39000003 | Integer | Display Type | The display type of the recipient. 0 = Standard mail user, 1 = Distribution List, 5 = Private Distribution List, 6 = Remote User
3003001f | String | Email/Exchange Address | Contains the email address for SMTP records, and MS-Exchange address for EX records.
3002001f | String | Address Type | Contains the address type of the record. SMTP for regular email address, EX for MS-Exchange address, FAX for fax address, and MAPIPDL for private distribution list.
3001001f | String | Display Name | Contains the display name of the recipient.
5ff6001f | String | Recipient Display Name | The original display name of the recipient. This property usually contains the same value as 3001001f.
5ff70102 | Binary | Recipient EntryID | The value of this property is usually identical to 0fff0102.
6003001f | String | Drop-Down Name | The value of this property is displayed in the AutoComplete drop-down,
39fe001f | String | SMTP Address | Contains the SMTP address of Exchange record.
60040003 | Integer | Record Weight | Contains the weight of the record, relative to the other records. Record with higher weight value get a better position in the records list.

What can you do with this edit mode ?

  1. Easily view the content of your NK2 files: NK2 files store the information in binary format that cannot be easily viewed in any text viewer or Hex viewer. This mode allows you to easily view all records and field values stored in your NK2 file.
  2. Find and fix corrupted records or fields: If your NK2 file doesn't work well or doesn't work at all, this mode allows you to locate and fix records with unusual fields and values.
  3. Search and replace in any other editor: With this mode, you can copy the entire text into the clipboard (Ctrl+A and then Ctrl+C) and then paste it into your favourite text editor. In the other editor, you can make changes with search and replace or any other feature that your editor provide. After you made all your changes, simply paste back the text with all your changes (Ctrl+A and then Ctrl+V)

Be Careful !

The raw text edit mode is very powerful, because it allows you to make any change you like, but if you make any mistake, you can easily make the record you edit unreadable by Outlook, and even ruin the entire NK2 and make it unusable. In order to avoid from any risk of losing your NK2 information, always backup your NK2 file before editing it in this mode.


NK2Edit Command-Line Options

/nk2file <Filename> | Start NK2Edit with the specified .NK2 filename. If you don't use this command-line option, the .NK2 file of the default Outlook profile is loaded.
/nk2_to_text <NK2 Filename> <Text Filename> | Convert NK2 file into a raw text file that can be edited with any Unicode text editor. After editing the file, you can convert it back into a valid NK2 file by using /text_to_nk2 command-line option.
/text_to_nk2 <Text Filename> <NK2 Filename> | convert a raw text file back into a valid NK2 file.
/nofirstbackup | By default, /text_to_nk2 and /script options automatically backup the nk2 if it's the first overwrite made by NK2Edit. If you don't want to create a backup, use /nofirstbackup parameter.
/nobackup | By default, /text_to_nk2 and /script options automatically backup the nk2 file on every save, into a filename with .NK2Edit.Cmd.bak extension. If you don't want to create this backup, use /nobackup parameter.
/script <Script Filename> <NK2 Source> <NK2 Destination> Allows you to run a simple script that can make changes, like adding new NK2 records, replacing values in existing records, or deleting unwanted records without displaying any user interface. The <Script Filename> parameter specifies the filename contains the script. The <NK2 Source> is the NK2 filename to load, and the <NK2 Destination> is the NK2 file to save your changes. If <NK2 Destination> is not specified, your changes will overwrite the filename specified in <NK2 Source> parameter.

For more information about scripting with NK2Edit, read this page.

/copy_default <Destination File> (Available only in licensed version)

Allows you to easily copy the NK2 file of the default profile into the specified destination filename. The default NK2 filename may be different from one computer to another, depending on the profile name and Outlook version, so this option provide you an easily way to backup/copy the NK2 file into another location.

You can use this command-line option to collect the NK2 files from all computers on your network, by using it in the logon script of Windows, for example:
NK2Edit.exe /copy_default "z:\nk2files\%computername%.nk2"
NK2Edit.exe /copy_default "z:\nk2files\%username%.nk2"

/generate_new_nk2 <Destination NK2 File> <Number Of Days> <Max Emails> <Sent Messages> <Received Messages> (Available only in licensed version)

Allows you to generate a completely new NK2 file from the email addresses found in your mailbox. When using this command-line option, NK2Edit scans the messages inside your mailbox, collects the email addresses, and then generates a completely new NK2 file with all email addresses found in the mailbox scan process.

Here's the description of the parameters:

  • Destination NK2 File: The NK2 file to save the collected emails list. If you specify $default, the NK2 file of the default Outlook profile will be overwritten.
  • Number Of Days: Specify the number of days to scan backward from the current date. For example: If you specify 60 in this parameter, NK2Edit will scan the email messages created in the last 60 days.
  • Max Emails: Maximum number of email addresses to collect. Be aware that the default maximum number of records in NK2 file is 1000 for Outlook 2003 and 2000 for Outlook 2007/2010. So it's recommended to keep this parameter value below these limits.
  • Sent Messages: Specifies whether to scan the email addresses in the messages you sent. 1 = Yes, 0 = No.
  • Received Messages: Specifies whether to scan the email addresses in the messages you received. 1 = Yes, 0 = No. It's recommended to set this parameter value to 0 in most cases, because when you set it to 1, email addresses of spam messages might be added into the created NK2 file.

Example:

  • Scan the email addresses of messages sent in the last 60 days, and stop the scan process after finding 500 email addresses. Save the found email addresses into myfile.nk2
    NK2Edit.exe /generate_new_nk2 "f:\temp\myfile.nk2" 60 500 1 0

Notice: For using this command-line option with 64-bit version of Outlook 2010, you must use the x64 version of NK2Edit. In all other cases, you should use the 32-bit version of NK2Edit.

/merge_files <Destination File> <Source File 1> <Source File 2> <Merge Mode> <MaxRecords> <Weight Mode> (Available only in licensed version)

Allows you to merge 2 NK2 files into one from command-line. The file you specify in <Source File 2> is merged into <Source File 1> and then the result is saved into the file your specify in <Destination File>. If <Source File 1> or <Source File 2> is specified as an empty string (""), the <Destination File> will be used as a source.

Here's the description of the parameters:

  • Destination File: The .nk2 file to save the final result.
  • Source File 1 and Source File 2: The 2 NK2 files to merge. The file in 'Source File 2' is merged into the file specified in 'Source File 1'. You can specify $default if you want to use the NK2 file of the default profile as a source. You can specify empty string ("") if you want to use the destination file as a source.
  • Merge Mode: Specify one of the following values:
    • 1 - Allow duplicate records
    • 2 - (Recommended) If email already exist, replace it with the new one.
    • 3 - If email already exist, don't add the record.
  • MaxRecords: Maximum number of records that will be added to the NK2 file. It's recommended to set this value to the default of Outlook, which is 1000 for Outlook 2003, and 2000 to Outlook 2007/2010.
  • Weight Mode: Determines how to handle the Weight value and records order after the files are merged. You can specify one of the following values:
    • 0 - Don't change anything.
    • 1 - Set the Weight value of all records to 1 (initial value).
    • 2 - (Recommended) Sort the records according to the Weight value of the merged records.

Examples:

  • Merge file2.nk2 into file1.nk2 with maximum limitation of 2000 records.
    NK2Edit.exe /merge_files "f:\temp\file1.nk2" "" "f:\temp\file2.nk2" 2 2000 2
  • Merge the NK2 file of the default profile into merged.nk2, without records limitation (MaxRecords = 0). You can put this line in a logon script and create a large NK2 file which contains the NK2 records of all users...
    NK2Edit.exe /merge_files "z:\nk2data\merged.nk2" "" $default 2 0 2
  • Merge existing nk2 file with important records into the NK2 file of the default profile.
    NK2Edit.exe /merge_files $default "" "z:\records.nk2" 2 1000 2
  • Merge 1.nk2 into 2.nk2 and then save the result into 3.nk2
    NK2Edit.exe /merge_files "3.nk2" "2.nk2" "1.nk2" 2 1000 2
/stext <Filename> | Export the list of all AutoComplete entries into a simple text file.
/stab <Filename> | Export the list of all AutoComplete entries into a tab-delimited text file.
/scomma <Filename> | Export the list of all AutoComplete entries into a comma-delimited text file.
/stabular <Filename> | Export the list of all AutoComplete entries into a tabular text file.
/shtml <Filename> | Export the list of all AutoComplete entries into HTML file (Horizontal).
/sverhtml <Filename> | Export the list of all AutoComplete entries into HTML file (Vertical).
/sxml <Filename> | Export the list of all AutoComplete entries to XML file.
/soutlook <Filename> | Export the list of all AutoComplete entries into a tab-delimited text file that can be used to import the emails/names list into the contacts of Outlook.
/sort <column> This command-line option can be used with other save options for sorting by the desired column. If you don't specify this option, the list is sorted according to the last sort that you made from the user interface. The <column> parameter can specify the column index (0 for the first column, 1 for the second column, and so on) or the name of the column, like "Email" and "Display Name". You can specify the '~' prefix character (e.g: "~Display Name") if you want to sort in descending order. You can put multiple /sort in the command-line if you want to sort by multiple columns.

Examples:
nk2edit.exe /shtml "f:\temp\nk2.html" /sort 2 /sort ~1
nk2edit.exe /shtml "f:\temp\nk2.html" /sort "~Type" /sort "Email"

/nosort | When you specify this command-line option, the list will be saved without any sorting.


Edit NK2 files from command-line.

NK2Edit allows you to write small and simple scripts that can add/modify/delete records in .NK2 files, and execute them from command-line, without displaying any user interface.

NK2Edit Script Features

  • NK2Edit scripts can be executed in the logon script of any computer (Starting from Windows 2000) without need of any installation.
  • NK2Edit scripts allow you to automatically remove specific types of NK2 records. For example, you can choose to remove all SMTP addresses, or you can choose to remove all SMTP addresses with specific domain.
  • NK2Edit scripts allow you to automatically fix common errors and problems that occurred in the NK2 files of all users in your organization. For example, if there was a change in any email address or in the MS-Exchange addresses, and the addresses stored in the NK2 are now invalid, simply create a script that modifies the old addesses to the new addresses, and the problem will be solved for all users at once.
  • NK2Edit scripts can also fix corrupted NK2 files: When NK2Edit script modifies the NK2 file, it also rebuilds the entire file and removes errors found in it, so if there is any problem in the NK2 file and Outlook cannot load it, there is a good chance that the problem will be solved after running the NK2 script.

Getting Started

A script can be executed from command-line by using /script parameter:
NK2Edit.exe /script <Script Filename> <NK2 Source> <NK2 Destination>

The <Script Filename> parameter specifies the filename contains the script commands. The <NK2 Source> is the NK2 filename to load, and the <NK2 Destination> is the NK2 file to save your changes. If <NK2 Destination> is not specified or you specify an empty string (""), your changes will overwrite the filename specified in <NK2 Source> parameter.
You can use /LogFile parameter in order diagnose problems with your script. When you use the /LogFile parameter, all actions made by the script are saved into the specified text file.

For NK2Edit with commercial license: You can also specify $default instead of the NK2 filename. When $default is specified, NK2Edit uses the NK2 file of the default Outlook profile, in the context of the user that executes the script.

Examples:
NK2Edit.exe /script "f:\scripts\myscript.txt" "C:\Documents and Settings\Administrator\Application Data\Microsoft\Outlook\Outlook.NK2"
NK2Edit.exe /script "f:\scripts\myscript.txt" "C:\Documents and Settings\Administrator\Application Data\Microsoft\Outlook\Outlook.NK2" "c:\temp\mynewfile.nk2"
NK2Edit.exe /script "f:\scripts\myscript.txt" $default
NK2Edit.exe /script "f:\scripts\myscript.txt" $default "" /LogFile "f:\%computername%.txt"
NK2Edit.exe /script "f:\scripts\myscript.txt" "C:\Documents and Settings\Administrator\Application Data\Microsoft\Outlook\Outlook.NK2" "" /NoBackup /LogFile "f:\mylog.txt"

Currently, the scripts of NK2Edit support the following commands:

  • If - Allows you to remove and modify existing records according to the specified condition.
  • Add - Allows you add new records, by specifying address type, name, and email/Exchange string.
  • MergeMode - Specifies the merge mode for Add command.
  • RemoveQuotes - Removes the single-quotes from the display names and drop-down names in all NK2 records.
  • RemoveDoubleQuotes - Removes double-quotes from the display names and drop-down names in all NK2 records.

It's possible that more commands will be added in the future according to customer's requests.

Automatic Backups

When editing NK2 file using a script, NK2Edit automatically creates 2 types of backups:
  • First Time Backup: This backup is created only in the first time that NK2Edit overwrite existing NK2 file. The backup file is saved with .NK2Edit.First.bak extension. If you don't want that this backup will be created, use /nofirstbackup commmand-line option.
  • Every Save Backup: This backup is created on every time that changes are made into existing NK2 file. The backup file is saved with .NK2Edit.Cmd.bak extension. If you don't want that this backup will be created, use /nobackup commmand-line option.

It's highly recommended to allow NK2Edit to backup the NK2 files, unless you maintain your own backup system. Making backups for NK2 files insure that if something goes wrong with your scripts, you'll be able to restore the original NK2 file.

General guidelines for NK2Edit scripts

  • The script commands are not case sensitive.
  • You can edit the script with notepad or any other text editor and then save it to Ascii or Unicode text file. If you have non-English characters in your script, it's recommended to save the file as Unicode.
  • You must write every command in separated line.

Using the 'If' command

The general syntax of 'If' command is:
If [FieldName] [Operator] [Value] [Action]

The [FieldName] may specify the following fields: AddressType, DisplayName, Email, DropDown, SearchString, and SMTPEmail (SMTP email For Exchange records only)
The [Operator] may specify the following values: Contain, Equal, BeginWith, NotContain, NotEqual, NotBeginWith.

The [Action] may contain one of the following actions to perform on the records:

  • Delete - Delete the record
  • NoDelete - Mark the record for 'no delete', so the record won't be deleted even if other 'if' command request to delete it.
  • Set [FieldName] [Value] - Set a value into the specfied string.
  • Replace [Find String] [Replace String] - Replace a string with a new string in all major fields.
  • ReplaceField [FieldName] [Find String] [Replace String] - Replace a string with a new string only in the specified field.
  • AutoFill - Automatically fill the DropDown Name and Search String of the record with the right values. It's recommended to use this action after Set or ReplaceField actions.
Here's some examples for using If command:
  • Delete all SMTP addresses:
    If AddressType equal "SMTP" Delete
  • Delete all Exchange addresses:
    If AddressType equal "EX" Delete
  • Delete all SMTP addresses except of email addresses of hotmail.com and msn.com: (The NoDelete command overrides the delete command)
    If AddressType equal "SMTP" Delete
    If Email Contain "@hotmail.com" NoDelete
    If Email Contain "@msn.com" NoDelete
  • Find the record with aaaaa@msn.com as email address, and change it to helloworld@msn.com as email and 'Hello World' as display name. Also, fill the appropriate values in the DropDown and Search string (AutoFill) .
    If Email Equal "aaaaa@msn.com" Set Email "helloworld@msn.com" Set DisplayName "Hello World" AutoFill
  • Find the record with support@nirsoft.net as email address and delete it:
    If Email Equal "support@nirsoft.net" Delete
  • Find all Exchange records (AddressType="EX") and change their address to a new server:
    If AddressType equal "EX" ReplaceField "Email" "/o=First Organization/ou=first administrative group" "/O=NirSoft Organization/OU=NirSoft"
  • Find all SMTP email addresses with @domain1.com and change their domain to @domain2.com
    Also, update the DropDown and Search strings according to the email address change (AutoFill).
    If AddressType equal "SMTP" ReplaceField "Email" "@domain1.com" "@domain2.com" AutoFill
  • Replace 'NirSoft' string to 'SoftNir' in all SMTP records. This change will affect all major fields, including the display name and the email address.
    If AddressType equal "SMTP" Replace "NirSoft" "SoftNir"

Using the 'Add' command

The general syntax of 'Add' command is:
Add [Address Type] [Email/Exchange String] [Display Name] {Display Type}

The {Display Type} is optional parameter that may contain the following values: 0 for standard mail user (default), 1 for distribution list, and 6 for remote user

Examples for using Add command:

  • Add "SMTP" "nirsofer@yahoo.com" "Nir Sofer"
  • Add "EX" "/o=First Organization/ou=first administrative group/cn=Recipients/cn=Nirs" "Nir Sofer"
  • Add "EX" "/o=First Organization/ou=first administrative group/cn=Recipients/cn=everyone" "Everyone" 1

If the Email address or Exchange account already exist, the MergeMode is used to detemine whether to add the record, replace it with the old one, or discard it.

Using the 'MergeMode' command

The general syntax of 'MergeMode' command is:
MergeMode [Mode Number]

Examples for using MergeMode command:

  • Specifies that the Add command should always add the record, even if it already exist (duplicates might be created):
    MergeMode 1
  • Specifies that if the email already exists, the Add command should replace it with the new one:
    MergeMode 2
  • Specifies that if the email already exists, the Add command should not add the record:
    MergeMode 3

Script example with all commands

if AddressType Equal "SMTP" Delete
if Email Contain "@hotmail.com" NoDelete
if Email Contain "@msn.com" NoDelete
if Email Equal "abcdefg@msn.com" Set Email "helloworld@msn.com" Set DisplayName "Hello World"
MergeMode 2
Add "SMTP" "nirsofer@yahoo.com" "Nir Sofer"
Add "SMTP" "abcdefg@hotmail.com" "abcdefg"
Add "EX" "/o=First Organization/ou=first administrative group/cn=Recipients/cn=Nirs" "Nir Sofer"
Add "EX" "/o=First Organization/ou=first administrative group/cn=Recipients/cn=everyone" "Everyone" 1
If AddressType equal "EX" ReplaceField "Email" "/o=First Organization/ou=first administrative group" "/O=NirSoft Organization/OU=NirSoft"
If AddressType equal "SMTP" ReplaceField "Email" "@domain1.com" "@domain2.com" AutoFill
If AddressType equal "SMTP" Replace "NirSoft" "SoftNir"
RemoveQuotes


The location of the NK2 file of Outlook

The location of the NK2 AutoCompelete file created by Outlook might be different from one computer to another, depending on the operating system and the version of Outlook.
Here's the rules for finding the location of your NK2 file:
  • For Outlook 2003/2007 with Windows 2000, Windows XP, or Windows Server 2003:
    The location of the nk2 file is C:\Documents and Settings\[User Profile]\Application Data\Microsoft\Outlook
    The name of the NK2 file is identical to the Outlook profile name, with .nk2 extension.

  • For Outlook 2003/2007 with Windows Vista, Windows 7, or Windows server 2008:
    The location of the nk2 file is C:\Users\[User Profile]\AppData\Roaming\Microsoft\Outlook
    The name of the NK2 file is identical to the Outlook profile name, with .nk2 extension.

  • For Outlook 2010 with Windows Vista, Windows 7, or Windows server 2008:
    The nk2 file is located in C:\Users\win764\AppData\Local\Microsoft\Outlook\RoamCache
    The name of the NK2 file is in the following format: Stream_Autocomplete_X_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.dat The X is the file index (usually 0) and AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA is a random 16-byte key in hexadecimal format.

  • For Outlook 2010 with Windows XP:
    The nk2 file is located in C:\Documents and Settings\[User Profile]\Local Settings\Application Data\Microsoft\Outlook\RoamCache
    The name of the NK2 file is in the following format: Stream_Autocomplete_X_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.dat The X is the file index (usually 0) and AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA is a random 16-byte key in hexadecimal format.

When you use the NK2Edit utility, you don't have to worry about locating the NK2 filename, because NK2Edit automatically open the default NK2 file for you.


NK2 Control Center

About NK2 Control Center

NK2 Control Center is a special module in NK2Edit utility that allows you to view the location and status of all NK2 AutoComplete files in your organization. In order to use this feature, you must add a single line into the logon script of every Outlook user. This script command is responsible for collecting the NK2 location and other information and saving it into one file.

Advantages of using NK2 Control Center

  • Automatically detect corrupted NK2 files that stopped working with Outlook, even if the users don't complain about that.
  • If you have admin access to the computers on your network (like \\compname\c$), you can easily open the NK2 file of every user with a single click. You don't have to search the location of the NK2 file.
  • Allows you to easily watch the summary of all NK2 files in your company, including the number of records of every NK2 file, the number of SMTP records, the number of MS-Exchange records, the size of the NK2 file, the full path of the NK2 filename, and the Outlook profile name.

Control Center License

The number of computers that you can view with NK2 Control Center is restricted according to the number of Outlook workstations in your license. For example, if you purchased 50 Workstations license, you are allowed to view up to 50 different computers.

NK2Edit without a commercial license allows you to watch up to 10 different computers.

Getting Started

In order to start using NK2 Control Center, you must add the following line into the logon script of every user:
NK2Edit.exe /saveinfo

The NK2Edit.exe should be located in a shared network folder that can be accessed by all users. When this command is executed, NK2Edit creates a file named 'nk2info.dat' in the same folder of NK2Edit.exe
If the users don't have write permission in the folder where NK2Edit is located, you must specify a filename in a shared network folder that every user has a write permission for it, for example:
NK2Edit.exe /saveinfo "G:\NK2Edit\nk2info.dat"

After adding this line, wait until the users make the next log-on, and then run NK2Edit and start the Control Center by pressing F2 key.
By default, the Control Center tries to read the nk2info.dat located in the same folder of NK2Edit. If you saved the file in another location, you have to manually select the file by using the 'Choose nk2info.dat' button.

If you have full admin share access to the remote computer on your network (\\computer\c$), you can easily open any file from the Control Center by using the 'Open Selected NK2 File' option (Ctrl+O).

Control Center Columns

  • Computer: The name of the computer.
  • User Name: The name of the user in a format of Domain\User.
  • Outlook Profile: The name of the default Outlook profile for the specified user.
  • Updated On: The date/time that the /saveinfo was executed.
  • Status: The status of NK2 file. This column may contain the following values:
    • File is Ok - This status is displayed when NK2Edit managed to read the NK2 file properly without any problem.
    • File contains unrecognized bytes - This status is displayed when NK2Edit managed to read all records, but some bad or unrecognized bytes were found in the file.
    • Record count mismatch - This status is displayed when the number of records found in the file ('Records Found' column) is different from records counter stored in the NK2 header ('Records Count' column).
    • Failed to read the file - This status is displayed when NK2Edit failed to read the NK2 file due to permission problem or any other file access issue.

    When the file status is not 'File is Ok', you should check whether the AutoComplete feature works properly in the specified workstation. If the AutoComplete feature doesn't work, you can fix it by following the NK2 file repair instructions. Be aware that after you repair the file, the status displayed on the Control Center won't be changed until the next update of the logon script.

  • Filename: The full-path filename of the NK2 file.
  • Records Count: The number of records according to the header of the NK2 file.
  • Records Found: The number of records found inside the NK2 file.
  • SMTP Records: The number of SMTP records found inside the NK2 file.
  • Exchange Records: The number of Exchange records found inside the NK2 file.
  • File Size: The size of the NK2 file.
  • Remote Network File:The path to access the NK2 file from another computer on your network. You must have admin access to use this path.