If you wish to extract the contacts’ photos and their primary information to a folder on your local disk in batches, you need to use Outlook VBA. This article will teach you how to achieve it in detail.
Outlook permits you to export the contact information via “Import and Export” feature. You can go to “File” > “Print” > “Import” > “Export to a file”.
However, this feature doesn’t allow you to export the contact photos. Thus, if you would like to extract both the contact information and photos, you have to recur to Outlook VBA. The followings are the VBA codes and steps which can save the contact photos to a specified local folder and extract the contact information into a text file.
Batch Export Multiple Contacts’ Photos and Information
- In the first place, launch Outlook and press “Alt + F11” key buttons.
- Then you will get access to VBA editor. Now you should open a module that is not in use or create a new module by “Insert” > “Module”.
- Subsequently, copy and paste the following VBA codes into the new module.
Sub BatchExportContactPhotosandInformation() Dim objContacts As Outlook.Items Dim objContact As ContactItem Dim strContactInfo As String Dim objFileSystem As Object Dim objTextfile As Object Dim objAttachments As Attachments Dim objAttachment As Attachment Dim strName As String 'Specify the contacts in the default contact folder Set objContacts = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items For Each objContact In objContacts If TypeOf objContact Is ContactItem Then 'Get the contact's primary informtaion strContactInfo = "Name: " & objContact.FullName & vbCrLf & "Email: " & objContact.Email1Address & vbCrLf & "Company: " & objContact.Companies & vbCrLf & "Job Title: " & objContact.JobTitle & vbCrLf & "Business Address: " & objContact.BusinessAddress & vbCrLf & "Business Phone: " & objContact.BusinessTelephoneNumber 'Create a Text file Set objFileSystem = CreateObject("Scripting.FileSystemObject") 'You can change the folder path as per your needs Set objTextfile = objFileSystem.CreateTextFile("C:\Outlook Contacts\" & objContact.FullName & ".txt", True) objTextfile.WriteLine (strContactInfo) 'Save the contact photos If objContact.Attachments.Count > 0 Then Set objAttachments = objContact.Attachments For Each objAttachment In objAttachments If InStr(LCase(objAttachment.filename), "contactpicture.jpg") > 0 Then strName = objContact.FullName & ".jpg" objAttachment.SaveAsFile ("C:\Outlook Contacts\" & strName) End If Next End If End If Next End Sub
Note: The above codes will export the photos and information of the contacts in your default contact folder. You can change the specified contacts.
- If you want to export the photos and information of the contacts in currently opened folder, then you should replace the “Set objContacts = …..” with:
Set objContacts = Outlook.Application.ActiveExplorer.CurrentFolder.Items
- If you only hope to export the photos and information of selected contacts, then you can use the following lines:
Dim objSelection as Selection Set objSelection = Outlook.Application.ActiveExplorer.Selection For each objContact in objSelection
- After that, you can close the VBA editor and proceed to add the new project to Quick Access Toolbar as usual.
- Finally you can click the macro button in Quick Access Toolbar. At once, the contact photos and information will be exported to the specified folder in local disk.
You can open one Text file, in which the primary information will be listed, like the following screenshot:
Handle Unexpected Outlook Corruption
It is an unquestioned fact that Outlook is vulnerable. Hence, if you suffer Outlook corruption, what you should do firstly is to calm down. Then you can continue to repair the corrupt Outlook PST email. You can use inbox repair tool to have a try. If it fails, then you have no choice but to employ a much more powerful tool, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair damaged SQL mdf database and outlook repair software products. For more information visit www.datanumen.com