• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Batch Import Photos into Outlook Contacts

Slipstick Systems

› Outlook › People › Batch Import Photos into Outlook Contacts

Last reviewed on December 4, 2018     46 Comments

Beginning with Outlook 2003, you could add contact photos to your contacts. Each contact needs to edited to add the image, however you can use VBA to automate the process. For best results, the image needs to be named the same as the contact, otherwise you need to use a lookup table to associate names with pictures.

To export contact photos to a folder on the hard drive, see Export (save) Outlook Contact photos. See "Import Images into the Active Directory" if you want to import photos into the Active Directory.

If the contact has a picture assigned and one exists in the folder, it will be replaced. If no picture exists, the contact is skipped. The screenshots below are before and after shots of the business card view. (Contact pictures are from Portrait Illustration Maker)
Contacts and contact photos

Business cards with contact photos

You can use the full name , "last, first" or FileAs format for the image name by changing the following line in the code (don't forget to change the file path and file extension if needed.):
strPhoto = "C:\photos\" & myContact.FullName & ".jpg"

myContact.FileAs uses the file as format on each contact
myContact.FullName for "first last.jpg" name format, ie "diane poremsky.jpg"
myContact.LastNameAndFirstName results in "last, first.jpg" format, or "poremsky, diane.jpg"

You can make up your own formats using Outlook fields. For example, if the file name is last first with no comma and a space (Poremsky Diane.jpg) use
strPhoto = "C:\photos\" & myContact.LastName & " " & myContact.FirstName & ".jpg"

If the names are lastfirst without a space (poremskydiane.jpg), use
strPhoto = "C:\photos\" & myContact.LastName & myContact.FirstName & ".jpg"

VBA code sample

Tested in Outlook 2007 and 2010.

Public Sub UpdateContactPhoto()
    Dim myOlApp As Outlook.Application
    Dim myNamespace As Outlook.NameSpace
    Dim myContacts As Outlook.Items
    Dim myItems As Outlook.Items
    Dim myItem As Object
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNamespace = myOlApp.GetNamespace("MAPI")
  
  ' use the default contacts folder
   Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items

  ' to use the selected folder use this line instead:
  '  Set myContacts = myOlApp.ActiveExplorer.CurrentFolder.Items

    Dim fs As Object
    Set fs = CreateObject("Scripting.FileSystemObject")
    For Each myItem In myContacts
        If (myItem.Class = olContact) Then
            Dim myContact As Outlook.ContactItem
            Set myContact = myItem

            Dim strPhoto As String
            
      '  use myContact.LastNameAndFirstName = "last, first.jpg" format
      '  replace "C:\photos\" with the correct path. 
            strPhoto = "C:\photos\" & myContact.FullName & ".jpg"
            
     ' use for testing only, to confirm the path is correct. 
     ' Delete or comment out 
    ' MsgBox (strPhoto)
                  
                  
            If fs.FileExists(strPhoto) Then
                myContact.AddPicture strPhoto
                myContact.Save
            End If
        End If
    Next
End Sub

How to use the code

Go to the Trust center and make macros are configured to notify. (File, Options, Trust center in Outlook 2010, Tools, Trust center in Outlook 2007.)
Outlook's trust center

Close and restart Outlook.

Press Alt+F11 to open the VBA editor and double click on ThisOutlookSession to open it in the editor.

Copy and paste the code into ThisOutlookSession.

Press the Run button (F5) to run the macro now. To run it later, use the Tools, Macro command (Outlook 2007).
VB Editor with code

Uncomment the 'MsgBox (strPhoto) line and run to verify the file path is correct. (Uncomment the line by removing the apostrophe from in front of the line.)

More Information

ContactItem.AddPicture Method (MSDN)
Sample images from Portrait Illustration Maker
Change Contact's File As format

Batch Import Photos into Outlook Contacts was last modified: December 4th, 2018 by Diane Poremsky

Related Posts:

  • Export (Save) Outlook Contact Photos
  • Categorize Contacts with bad addresses
  • Outlook.com Contact Photos
  • Use Instant search to find messages from a contact

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
46 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Graham (@guest_212845)
March 1, 2019 4:59 am
#212845

Wow. This worked first time - I did my preparation though.
An old post but still useful. I am migrating from Gmail to O365. In Gmail the pictures can bulk be exported to CSV but endup as a http link to a JPG. I used Excel to prepare a PowerShell WGET to pull down the JPG and name it correctly. Then ran your script.

  1. Follow
    MS instructions to export/import without photos.
  2. Do above again but use Google CSV format, to separate file
  3. Perform Excel wizardry to create named photos in directory
  4. Use your wonderful script

=IF(ISBLANK([@Photo]),,CONCAT("wget ",[@Photo]," -outfile """,[@Name],".jpg"""))

Thank you so much.

0
0
Reply
Rob (@guest_205922)
April 15, 2017 5:47 am
#205922

How do I set all contacts where the CompanyName is 'Acme' (for example) to update with a set photo? So I have one image I would like to apply to all contacts in one company but not touch any other contacts, how do I do that please?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Rob
April 15, 2017 7:47 am
#205923

Change myContact.FullName to myContact.companyname - and name the image to match the company name. this will change all contacts to use company logos as the photo. If only contacts from acme need the photo matched to the company name, editing the macro to work with selected contacts might be easier - then select all contacts from one company and run it. https://www.slipstick.com/developer/code-samples/working-items-folder-selected-items/

now... do you really want to use the photo in the contact or add the image to the business card view? i have a macro for that too.

0
0
Reply
Curtis Spurlock (@guest_204677)
February 16, 2017 6:16 pm
#204677

When I ran the macro I got an error:

Run time error 91:
Object or With block variable not set

0
0
Reply
Steven Reames (@guest_198544)
May 9, 2016 12:56 pm
#198544

This is brilliant. I imported my photo file name to a user field in Outlook and linked it from there instead of cross referencing to another table.

Can I buy you coffee today?

0
0
Reply
enrique@ibicsa.co.cu (@guest_198118)
April 22, 2016 10:17 am
#198118

whats happen if i don this process in my pc , them export address book to import in other s workstation? is possible? thaks srry abaut my english

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  enrique@ibicsa.co.cu
April 22, 2016 10:26 am
#198119

if you export to a pst file, you'll be fine. If you export to a csv, you won't have the images.

0
0
Reply
Syed Nazar (@guest_194670)
November 10, 2015 7:03 am
#194670

Guys there is a easy no need to write and execute the Script use this software and very simple to upload photos
[software name removed]

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Syed Nazar
November 10, 2015 7:48 am
#194671

If you had read the page, you'd know the script on this page tells end-users how to import photos into their Outlook Contacts, not into the Active Directory.

PowerShell scripts to bulk import into the AD are at Import Images into the Active Directory. That page has a list of utilities for those who don't want to use PowerShell directly.

0
0
Reply
Clark (@guest_186123)
September 20, 2014 12:30 am
#186123

Hi, Thank you, I have it working now!! It seems to work on my default email only when i change to my other email addresses it doesn't work. Do I need to change something? Thanks again this has saved me hours and hours

0
0
Reply
Diane Poremsky (@guest_186124)
Reply to  Clark
September 20, 2014 12:50 am
#186124

Oh, i forgot to mention - as written, its for the default contacts folder. I'll put up a version that works on selected contacts.

0
0
Reply
Diane Poremsky (@guest_186125)
Reply to  Clark
September 20, 2014 12:53 am
#186125

Use this line to work on the selected folder:
Set myContacts = myOlApp.ActiveExplorer.CurrentFolder.Items

that will replace this line:
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items

0
0
Reply
Clark (@guest_186120)
September 19, 2014 11:35 pm
#186120

Hi Can you please check what I have done, I cant seem to get running:

Public Sub UpdateContactPhoto()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items

Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
For Each myItem In myContacts
If (myItem.Class = olContact) Then
Dim myContact As Outlook.ContactItem
Set myContact = myItem

Dim strPhoto As String

' use myContact.Categories & ".jpg” format
' replace “D:\Hybrid Clark\Standard Documents\Hybrid Data\Hybrid - Icons\Outlook”
strPhoto = “D:\Hybrid Clark\Standard Documents\Hybrid Data\Hybrid - Icons\Outlook” & myContact.Categories & “.jpg”

' use for testing only, to confirm the path is correct.
' Delete or comment out
' MsgBox (strPhoto)

If fs.FileExists(strPhoto) Then
myContact.AddPicture strPhoto
myContact.Save
End If
End If
Next
End Sub

I have changed the following:

1. ' use myContact.Categories & ".jpg” format
2. ' replace “D:\Hybrid Clark\Standard Documents\Hybrid Data\Hybrid - Icons\Outlook”
strPhoto = “D:\Hybrid Clark\Standard Documents\Hybrid Data\Hybrid - Icons\Outlook” & myContact.Categories & “.jpg”

The path to the photos is long. Thanks for your help Clark

0
0
Reply
Diane Poremsky (@guest_186121)
Reply to  Clark
September 20, 2014 12:11 am
#186121

It's working here. The category name is case sensitive - if it's Cat1 in outlook, you need to call the image Cat1. The extension needs to be correct too. Oh - and the file path needs a \ at the end "D:\Hybrid Clark\Standard Documents\Hybrid Data\Hybrid - Icons\Outlook\" - otherwise it's looking for an image called OutlookCategoryName.jpg

Category images

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 28 Issue 27

Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Subscribe to Exchange Messaging Outlook






Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Outlook: Web Bugs & Blocked HTML Images
  • How to Remove the Primary Account from Outlook
  • Adjusting Outlook's Zoom Setting in Email
  • Move an Outlook Personal Folders .pst File
  • Save Sent Items in Shared Mailbox Sent Items folder
  • This operation has been cancelled due to restrictions
  • Remove a password from an Outlook *.pst File
  • Use PowerShell to get a list of Distribution Group members
  • Outlook Auto Account Setup: Encrypted Connection not available
  • Create rules that apply to an entire domain
  • How to Block Foreign Spam
  • Automatically Open New Outlook when Windows boots
  • Block External Content in New Outlook
  • Save Messages in New Outlook
  • Send Individual Messages when Sending Bulk Email
  • Centrally managed signatures in Office 365?
  • Create a rule to delete spam with no sender address
  • Open Outlook Folders using PowerShell or VBScript
  • Cannot add Recipients in To, CC, BCC fields on MacOS
  • Change Appointment Reminder Sounds
Ajax spinner

Newest Code Samples

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

Format Images in Outlook Email

Set Outlook Online or Offline using VBScript or PowerShell

List snoozed reminders and snooze-times

Search your Contacts using PowerShell

Filter mail when you are not the only recipient

Add Contact Information to a Task

Process Mail that was Auto Forwarded by a Rule

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in Outlook for Windows.

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




Windows 10 Issues

  • iCloud, Outlook 2016, and Windows 10
  • Outlook Links Won’t Open In Windows 10
  • Outlook can’t send mail in Windows 10: error Ox800CCC13
  • Missing Outlook data files after upgrading Windows?

Outlook Top Issues

  • The Windows Store Outlook App
  • The Signature or Stationery and Fonts button doesn’t work
  • Outlook’s New Account Setup Wizard
  • Outlook 2016: No BCM
  • Exchange Account Set-up Missing in Outlook 2016

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Contact Tools

Data Entry and Updating

Duplicate Checkers

Phone Number Updates

Contact Management Tools

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2023 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment