Hi Patrick,
Just wanted to give you feedback on this macro and thank you. I didn't even know what a "macro" did when I read your posts today, but I did my homework and was able to get it up and running in Outlook and it is WONDERDFUL! I even made a toolbar button for it, like you suggested. My photo editor program took FOREVER to load up the pics when I opened them, and it was driving me CRAZY. You saved my sanity! Thanks so much!
Kristina
----- P_Lee wrote: -----
Updated version of the view attachments macro.
- Saves files in temporary internet folders instead of creating directory.
Files are automatically deleted from temporary folders when Outlook is closed.
- Allows right-click of image to 'Save As', 'Email', 'Print' etc. (previous
version deleted files, so this functionality did not work).
- Fixed auto resizing of images to browser width (previous version sometimes
didn't resize extremely large images the first time). If you want to resize
manually just resize the browser window, right-click, & choose 'Refresh' to
scale the images to the new browser width.
Please try it out & give me some feedback....
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub view_attachments()
'********************************************************************
' ver. 1/21/04 - Copies files to Temporary Internet folders.
' This enables right-click access to 'Save As', 'Email', etc.
' Files are automatically deleted when Outlook is closed.
'********************************************************************
On Error Resume Next
Dim oOL As Outlook.Application
Dim oSelection As Outlook.Selection
Set oOL = New Outlook.Application
Set oSelection = oOL.ActiveExplorer.Selection
Set objShell = CreateObject("WScript.Shell")
vTempInt = objShell.RegRead("HKCU\software\microsoft\" _
& "Windows\CurrentVersion\Explorer\Shell Folders\Cache")
vPath = vTempInt & "\"
vHTMLBody = "<HTML><title>View Email Attachments</title>"
vEmailNum = 0
For Each obj In oSelection
vEmailNum = vEmailNum + 10
vSubject = "<FONT face=Arial size=3>Attachments from: <b>" _
& obj.Subject & "</b><br>"
vHTMLBody = vHTMLBody & vSubject
vAttachNum = vEmailNum
For Each Attachment In obj.Attachments
vAttachNum = vAttachNum + 1
vImg = "document.img" & vAttachNum
Attachment.SaveAsFile (vPath & Attachment.FileName)
vHTMLBody = vHTMLBody & Attachment.FileName & "</Font><br>" _
& "<IMG name=""img" & vAttachNum & """" & " alt=""""" _
& " hspace=0 src=""" & vPath & Attachment.FileName _
& """ align=baseline border=0 " & "onload=""" _
& "vWidth=document.body.clientWidth;" _
& "if (" & vImg & ".width > vWidth) {" _
& vImg & ".width = vWidth;}""" _
& "><br><br><br>"
Next
Next
vHTMLBody = vHTMLBody & "</html>"
Set ie = CreateObject("internetexplorer.application")
With ie
.toolbar = 0
.menubar = 0
.statusbar = 0
.Left = 100
.Top = 50
.Height = 600
.Width = 800
.navigate "about:blank"
.document.Open
.document.Write vHTMLBody
.document.Close
.Visible = True
End With
Do Until ie.readyState = 4: Sleep 10: Loop
Set ie = Nothing
Set objShell = Nothing
Set objMsg = Nothing
Set oSelection = Nothing
Set oOL = Nothing
End Sub