Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLKxxx files mistery 1

Status
Not open for further replies.

eman6

Programmer
Dec 7, 2004
578
CH
When I open an attachment from outlook and then click File_Save As, it leads me by default to this location:
C:\Documents and Settings\Somebody\Local Settings\Temporary Internet Files\OLK108

However, if I try to open this same path in windows explorer, I either cannot find it or when I do find it (using the search facility) then I don't see the contents of this folder even with hidden files view set on (Tools_Folder Options).

Is there a way I can reach these files, relocate them? Open them?....


_______________________________________

Eman_2005
Technical Communicator
 
eman2005,
this is a temp folder. i believe it will still be there as long as you outlook session is still active. to save to a different location try using the drop down in the saveas dialog box and selecting another location.
hth
regards,
longhair
 
Thank you for your reply, Longhair
However, I wanted to access the existing files from that folder and do whatever I want to them (copy, delete, move, open, etc).
Unfortunately, the files stored in this folder are not visible by Windows Explorer.

_______________________________________

Eman_2005
Technical Communicator
 
eman2005,
i think the file is actually resaved to the email if you don't change the path. hence, the prompt to save the email when you go to close it. if you stll have the emails, you still have the files.
hth
regards,
longhair
 
Then I will have to open each and every one of hundreds of files to deal with each attachment email by email, one by one.

_______________________________________

Eman_2005
Technical Communicator
 
eman2005,
you can do that or....
Code:
Sub MySaveAs()
    Dim objApp As Outlook.Application
    Dim objSel As Outlook.Selection
    Dim x As Integer
    Dim sSubjectName As String
    Dim ynTried As Boolean
    Dim dteDate As String
    Dim fs
    Dim myPath As String
    Dim Final As String
    
'   Find the currently selected emails
    Set objApp = CreateObject("Outlook.Application")
    Set objSel = objApp.ActiveExplorer.Selection
    dteDate = Format(Date - 3, "MM-DD-YY")
    Set fs = CreateObject("Scripting.FileSystemObject")
    Final = "c:\test\" & dteDate
    MkDir Final

' For each email
    For x = 1 To objSel.Count
        With objSel.Item(x)
        ' perform save only on selected mail messages
            If .Class = olMail Then
            ' some subjects are unsuitable for file names
            ' so allow renaming if necessary
                sSubjectName = .Subject
                ynTried = False
                If InStr(1, sSubjectName, Asc(58), 1) Then GoTo ErrorSaving
                On Error GoTo ErrorSaving
                .SaveAs Final & "\" & sSubjectName & x & ".msg", olMSG
                'On Error GoTo 0
            End If
        End With
    Next
    Set objSel = Nothing
    Set objApp = Nothing
    Exit Sub
    
ErrorSaving:
    If ynTried Then 'they only get one chance to rename the message
        MsgBox "The message '" & sSubjectName & "' was not saved successfully", vbOKOnly, "Save Failed"
        Resume Next 'skips the save
    Else
    ' get a new subject name from user
        ynTried = True
        MsgBox (sSubjectNames & " not a valid name")
        sSubjectName = InputBox("Error:  Subject name not suitable.  Please type a new name excluding any special characters (i.e. :,'.!@ etc)", _
                "Save Failed", sSubjectName)
        Resume
    End If
End Sub
the above code should save each highlighted email for you. it's been awhile since i've used it, with a little tinkering yuo should be able to get it to work. please note this saves the entire email. make sure to check that your file is still with it before you delete it from outlook.
another option is to search the vba forum on tek-tips. i think there was a thread recently about automatically saving outlook attachments.
hth
regards,
longhair
 
That is cool, Longhair.
I am sure there is a way to modify this code so that it saves the attachments selectively.
I'll have a close look at this.
I have done a good deal of VB and VBA in Word, so I think this should be manageable.

Many thanks


_______________________________________

Eman_2005
Technical Communicator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top