我又看了一眼shahkalpeshs的回答,得出了以下解决方案:
(写在Outlook 2003中)
Option Explicit
Private Sub getImages()
Dim xmlhttp_ As xmlhttp
Dim htmldoc As Object
Dim currentImage As Object
Dim currentResponse() As Byte
Dim startTime As Date
Dim maxTime As Long
Dim pathFolder As String
Dim pathFull As String
Dim nrFile As Integer
pathFolder = "C:\YourFolder\Images\" '"(small fix for stackoverflow syntaxhighlighter)
maxTime = 30 ' max time to load 1 File in seconds '
If Me.ActiveWindow.CurrentItem.GetInspector.EditorType = olEditorHTML Then
Set htmldoc = Me.ActiveWindow.CurrentItem.GetInspector.HTMLEditor
Set xmlhttp_ = New xmlhttp
For Each currentImage In htmldoc.images
xmlhttp_.Open "GET", currentImage.src
If Left(currentImage.src, 8) <> "BLOCKED:" Then
xmlhttp_.Send
startTime = Now
pathFull = pathFolder & currentImage.nameProp
pathFull = Replace(pathFull, "?", vbNullString)
pathFull = Replace(pathFull, "&", vbNullString)
Do While xmlhttp_.readyState <> 4
If DateTime.DateDiff("s", startTime, Now) > maxTime Then Exit Do
DoEvents
Loop
If xmlhttp_.readyState = 4 Then
If Dir(pathFull) <> "" Then Kill pathFull
nrFile = freeFile
Open pathFull For Binary As #nrFile
currentResponse = xmlhttp_.responseBody
Put #nrFile, , currentResponse
Close #nrFile
End If
End If
Next currentImage
End If
Set xmlhttp_ = Nothing
Set currentImage = Nothing
Set htmldoc = Nothing
End Sub
此代码将下载
显示
在你的
ActiveWindow
把它们保存在一个文件夹里。
您需要添加对
Microsoft XML
(任何版本>=2.6都可以)通过VBA编辑器中的工具->引用
如果需要,还可以设置对
微软HTML对象库
并更改:
Dim htmldoc As Object
Dim currentImage As Object
致:
Dim htmldoc As HTMLDocument
Dim currentImage As HTMLImg
关于你的评论:
@玛格,谢谢你的详细回复。我仍然不敢相信解决方案必须如此复杂-图像已经显示,为什么我必须再次下载它?如果我只想保存一张图片呢?(在Outlook 2003中,您可以右键单击图像并选择另存为。。。因为这是一个接近实际可行的解决方案,而且在当前的前景中似乎没有更好的解决方案-我给你赏金。。。
我没有2007年寻找非编程解决方案。
我不相信
MailItem
对象(
CurrentItem
在我的解决方案中是
邮件
)不同的版本之间有很大的不同(但我基于0%的研究:D)并且我无法找到显示图像存储的直接本地路径,即使我非常确定它们应该在浏览器缓存文件夹中。正在爬网文件夹中的文件名
currentImage.nameProp
将其复制到目标文件夹将是另一种解决方案。简单地重装映像不应该那么糟糕:D