次の方法で共有


RemovePicture Method

Removes a picture from a Contacts item. Returns Nothing.

expression.RemovePicture

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Example

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 myOlApp As Outlook.Application
    Dim myNms As Outlook.NameSpace
    Dim myFolder As Outlook.MAPIFolder
    Dim myContactItem As Outlook.ContactItem
    Dim strName As String
    Dim strPath As String
    Dim strPrompt As String
    Set myOlApp = CreateObject("Outlook.Application")
        
    Set myNms = myOlApp.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

Applies to | ContactItem Object