ContactItem.RemovePicture Method (Outlook)

Removes a picture from a Contacts item.

expression .RemovePicture

expression A variable that represents a ContactItem object.

The following Microsoft Visual Basic for Applications (VBA) example prompts the user to specify a name of a contact and removes the picture from the contact item. If a picture does not exist for the contact, the example displays a message to the user.

Sub RemovePictureFromContact() 
 
 Dim myNms As Outlook.NameSpace 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myContactItem As Outlook.ContactItem 
 
 Dim strName As String 
 
 Dim strPath As String 
 
 Dim strPrompt As String 
 
 
 
 Set myNms = Application.GetNamespace("MAPI") 
 
 Set myFolder = myNms.GetDefaultFolder(olFolderContacts) 
 
 strName = InputBox("Type the name of the contact: ") 
 
 Set myContactItem = myFolder.Items(strName) 
 
 If myContactItem.HasPicture = False Then 
 
 MsgBox "The contact does not have a picture associated with it." 
 
 Else 
 
 myContactItem.RemovePicture 
 
 myContactItem.Save 
 
 myContactItem.Display 
 
 End If 
 
End Sub
Show:
© 2014 Microsoft