I had a second look at shahkalpeshs answer and came up with the following solution: (Written in 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
This code will download all images in ActiveWindow and save them in a folder.
You will need to add a link to Microsoft XML (any version> = 2.6 should work) using the tools-> Links in the VBA editor
If you want, you can also set the link to the Microsoft HTML Object Library and change:
Dim htmldoc As Object Dim currentImage As Object
in
Dim htmldoc As HTMLDocument Dim currentImage As HTMLImg
Regarding your comment:
@marg, Thanks for the detailed answer. I still cannot believe that the solution should be so confusing - the image is already displayed, why should I download it again? But what if I want to save only one image? (In Outlook 2003, you were able to right-click on the image and choose to save as ... now no more.) Since this is a close for a real workable solution, and since there is no better solution in current Outlook - I give you generosity ...
I do not have 2007 to search for a non-programming solution.
I donโt think the MailItem Object ( CurrentItem in my solution is MailItem ) is very different between versions (but I base this assumption on 0% research: D) and I couldnโt find the direct local path where the displayed images are stored, although I sure that they should be in the browser cache folder. An alternative solution would be to bypass your folder for the file named currentImage.nameProp and copy it to the destination folder. Just reloading the image should not be so bad: D
marg
source share