如何以编程方式在Outlook 2007中设置联系人图像?

时间:2009-11-04 20:56:16

标签: image contact

我们如何在Outlook 2007中自动/以编程方式设置发件人/联系人图像?他们是同事,所有员工照片都存储在netshare中。

1 个答案:

答案 0 :(得分:1)

我看到Outlook.ContactItem有一个AddPicture方法。以下是帮助文件中的一个示例:

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