Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba Outlook获取Exchange用户图片_Vba_Excel_Vbscript_Outlook - Fatal编程技术网

Vba Outlook获取Exchange用户图片

Vba Outlook获取Exchange用户图片,vba,excel,vbscript,outlook,Vba,Excel,Vbscript,Outlook,我正在尝试为通讯组列表中具有特定名称的用户获取图片。在OutlookVBA中,代码可以正常工作。在EXCEL VBA中,调用getpicture时代码失败。从通用VBS运行代码时,代码执行getpicture调用,但返回null。然而,getexchangeuser调用在这三种情况下都有效。我需要帮助获取图片,然后保存它,这取决于在VBA中是否难以保存格式 Sub test() HeroName = "test" HLastName = Split(HeroName, " ")(

我正在尝试为通讯组列表中具有特定名称的用户获取图片。在OutlookVBA中,代码可以正常工作。在EXCEL VBA中,调用
getpicture
时代码失败。从通用VBS运行代码时,代码执行
getpicture
调用,但返回null。然而,
getexchangeuser
调用在这三种情况下都有效。我需要帮助获取图片,然后保存它,这取决于在VBA中是否难以保存格式

Sub test()
    HeroName = "test"
    HLastName = Split(HeroName, " ")(1)
    Dim olApp As Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olAL As Outlook.AddressList
    Dim olEntry As Outlook.AddressEntry
    Dim olMember As Outlook.AddressEntry
    Dim lMemberCount As Long
    Dim objMail As Outlook.MailItem
    Set olApp = Outlook.Application
    Set olNS = olApp.GetNamespace("MAPI")
    Set olAL = olNS.AddressLists("Global Address List")
    Set objMail = olApp.CreateItem(olMailItem)
    ' enter the list name
    Set olEntry = olAL.AddressEntries("##distribution list##")
    ' get count of dist list members
    lMemberCount = olEntry.Members.Count
    ' loop through dist list and extract members
    Dim i As Long
    For i = 1 To lMemberCount
        Set olMember = olEntry.Members.Item(i)
        ' NONE OF THIS CODE IS NECESSARY UNLESS IN THE FUTURE SVIL HAS MEMBERS WHO SHARE THE SAME LAST NAME
        'AS A RESULT THE CODE IS NOT BEING UTILIZED
        strName = olMember.Name
        LastName = Split(strName, ",")(0)
        'MsgBox (LastName)
        If (InStr(HLastName, LastName)) Then
            MsgBox (LastName)
            'ActiveWorkbook.Sheets("Sheet2").Pictures.Insert
            Dim returnValue As StdPicture
            'MsgBox (olMember.GetExchangeUser)
            'MsgBox (olMember.GetExchangeUser.GetPicture)
        End If
    Next i
End Sub

`

只有在outlook.exe进程内运行时才能检索图片,即如果您的代码位于outlook VBA或COM加载项中:

发件人:


只能从作为Outlook在进程中运行的代码中调用GetPicture。无法跨进程边界封送StdPicture对象。如果您试图从进程外代码调用GetPicture,则会发生异常

但是,您知道是否有任何方法可以通过VB脚本或VBA实例化outlook应用程序,然后运行outlook脚本吗?没有,但您可以阅读PR\EMS\u AB\u缩略图\u照片(DASL名称<代码>http://schemas.microsoft.com/mapi/proptag/0x8C9E0102)使用AddressEnttry.PropertyAccessor.GetProperty,然后将其另存为JPG文件。