Downloading Outlook contact photos / profile pictures

Sample Outlook Profile imageI wanted to grab the photos (“ContactPicture”) that people put in their Outlook Contact Details.

Not sure if I grabbed this code from somewhere, or wrote it myself.  Just leaving it here for the next time I need it.

Note to self:
* you need a local copy of the address book to run this code against.

Sub SaveContactPhoto()
Dim itemContact As ContactItem
Dim fdrContacts As MAPIFolder
Dim colAttachments As Outlook.Items
Dim colItems As Outlook.Items
Dim fname As String
'Default Contacts folder
'Set fdrContacts = Session.GetDefaultFolder(olFolderContacts)
' Selected folder
' Ensure you select the GAL folder ....
Set fdrContacts = Application.ActiveExplorer.CurrentFolder
On Error Resume Next
For itemCounter = 1 To fdrContacts.Items.Count
    Set itemContact = fdrContacts.Items(itemCounter)
    Set collAttachments = itemContact.Attachments
    For Each attach In collAttachments
      If attach.FileName = "ContactPicture.jpg" Then
         fname = (itemContact.FirstName & " " & itemContact.LastName & ".jpg")
        If fname <> "" Then
            attach.SaveAsFile ("C:\data\Contact Photos\" & fname)
        End If
      End If
End Sub

Bonus fact: Microsoft call the Outlook Contact Details “Profile Cards”

Microsoft commits to releasing Outlook PST format

This is big news, particularly if you’ve ever tried to convert an OST file to a PST file.

… In order to facilitate interoperability and enable customers and vendors to access the data in .pst files on a variety of platforms, we will be releasing documentation for the .pst file format.  This will allow developers to read, create, and interoperate with the data in .pst files in server and client scenarios using the programming language and platform of their choice.  The technical documentation will detail how the data is stored, along with guidance for accessing that data from other software applications.  It also will highlight the structure of the .pst file, provide details like how to navigate the folder hierarchy, and explain how to access the individual data objects and properties….
Paul Lorimer, Group Manager, Microsoft Office Interoperability

Bookmark and Share

How to convert an OST file to a PST file

(if you don’t know what an OST file is, see below)

There are four options, one of these below might work for you.
NOTE: This is a work in progress post.  It will be updated when I learn something.

The OST2PST conversation method.

  1. Backup ost file(s)
  2. Rename outlook.ost to outlook.pst
  3. Use scanpst.exe from Outlook 2002 (in C:\Program Files\Common Files\System\Mapi\1033) to repair outlook.pst
    (You can always copy scanpst.exe from an alternative installation, include MAPI32.DLL and GAPI32.DLL)
  4. Rename outlook.pst back to outlook.ost
  5. Run OST2PST which will then convert the file successfully to outlook.pst
  6. Outlook can then open the outlook.pst file

MS Exchange Blog: OST to PST
Geeks To Go: Converting Outlook .OST files to .pst

This method may not work with Outlook 2003 or later OST files.

Modify the header file method
The type of Outlook file, whether it is a PST or OST, is stored in the header of the file.
It might be possible to modify the header, and open the modified file in Outlook.

The file format has been documented in “Personal Folder File (PFF) forensics” by Joachim Metz.

Compile and use the pffexport program method
“Extracts items from a Personal Folder File (OST or PST)”.  See the libpff site.

Buy any number of commercial products method.
I’ve tried none of these.  You are on your own.

Product Name Cost (in US Dollars)
Recovery Toolbox for Outlook $50 –> $90
Kernel Recovery for OST $249 –> $399
Recover Data for OST to PST $99 –> $299
Advanced Exchange Recovery $250
Quick Recovery for OST to PST $129 –> $229

So what is an OST file then?
If you’re asking this question, you probably don’t need to know.  🙂

An Outlook Offline Storage Table (OST) file is a copy of your Exchange email account.  This copy allows you to access your (offline) email while you are not connected to a network.  Such as when you are travelling..

Update October 2009: Roadmap for Outlook Personal Folders (.pst) Documentation

Bookmark and Share