ContactItem 属性 (Outlook)ContactItem.HasPicture property (Outlook)

返回一个布尔值, 如果联系人项目具有与之关联的图片, 则为TrueReturns a Boolean value that is True if a Contacts item has a picture associated with it. 只读Read-only

语法Syntax

expressionexpression. HasPicture

_表达式_一个代表ContactItem对象的变量。expression A variable that represents a ContactItem object.

示例Example

以下 Microsoft Visual Basic for Applications (VBA) 示例提示用户指定联系人姓名和含有联系人图片的文件名称,然后将图片添加到联系人项目。The following Microsoft Visual Basic for Applications (VBA) example prompts the user to specify the name of a contact and the file name containing a picture of the contact, and then adds the picture to the contact item. 如果联系人项目图片已经存在,将提示用户是否用新文件覆盖现有图片。If a picture already exists for the contact item, the example prompts the user to specify if the existing picture should be overwritten by the new file.

Sub AddPictureToAContact() 
 
 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 = True Then 
 
 strPrompt = MsgBox("The contact already has a picture associated with it. Do you want to overwrite the existing picture?", vbYesNo) 
 
 If strPrompt = vbNo Then 
 
 Exit Sub 
 
 End If 
 
 End If 
 
 strPath = InputBox("Type the file name for the contact: ") 
 
 myContactItem.AddPicture (strPath) 
 
 myContactItem.Save 
 
 myContactItem.Display 
 
End Sub

另请参阅See also

创建 ContactItem 对象ContactItem Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.