Outlook获取Exchange用户图片

我正在试图获取具有特定名称的用户在分发列表中的图片。 在OUTLOOK VBA中,代码起作用。 在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插件中,

https://msdn.microsoft.com/zh-CN/library/office/ff864210.aspx

您只能从Outlook运行的进程中调用GetPicture。 一个StdPicture对象不能跨进程边界封送。 如果您尝试从进程外代码调用GetPicture,则会发生exception