View Single Post
 
Old 12-05-2017, 02:27 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Obviously I cannot check in your father's unknown Outlook version, but he may be able to use the following Outlook Macros (which I have posted here before) to save the messages in his inbox and its sub folders as Word compatible RTF format.

This will take a while to run without much indication of progress. However because of the forum format I have commented out the references to the progress indicator that would correct this issue.

He will also need sufficient disc space to store hundreds of messages in RTF format.

The code takes no account of attachments that may be attached to the messages.

If you want the progress indicator, you can download it from http://www.gmayor.com/Zips/ProgressBar.zip and resurrect the userform commands

Code:
Option Explicit

Sub SaveMessages()
'Graham Mayor - http://www.gmayor.com
Dim cFolders As Collection
Dim olFolder As Outlook.Folder
Dim subFolder As Outlook.Folder
Dim olNS As Outlook.NameSpace
Dim strPath As String
Dim sSubPath As String
Dim sStore As String

    strPath = InputBox("Enter the path to save the messages." & vbCr & _
                       "The path will be created if it doesn't exist.", _
                       "Save Message", "C:\Outlook Message Backup\")

    Do Until Right(strPath, 1) = Chr(92)
        strPath = strPath & Chr(92)
    Loop

    Set cFolders = New Collection
    Set olNS = GetNamespace("MAPI")
    cFolders.Add olNS.GetDefaultFolder(olFolderInbox)
    Do While cFolders.Count > 0
        Set olFolder = cFolders(1)
        cFolders.Remove 1
        sStore = olFolder.Store
        sSubPath = Replace(olFolder.FolderPath, "\\" & sStore & "\", strPath)
        CreateFolders sSubPath
        ProcessFolder olFolder, sSubPath
        If olFolder.folders.Count > 0 Then
            For Each subFolder In olFolder.folders
                cFolders.Add subFolder
            Next subFolder
        End If
    Loop
lbl_Exit:
    Set olFolder = Nothing
    Set subFolder = Nothing
    Exit Sub
End Sub

Private Sub ProcessFolder(olMailFolder As Outlook.Folder, sPath As String)
'Graham Mayor - http://www.gmayor.com
Dim olItems As Outlook.Items
Dim olMailItem As Outlook.MailItem
Dim i As Long
    'Dim oFrm As New frmProgress
Dim PortionDone As Double

    On Error GoTo err_Handler

    Set olItems = olMailFolder.Items
    'oFrm.Show vbModeless
    i = 0
    For Each olMailItem In olItems
        i = i + 1
        'PortionDone = i / olItems.Count
        'oFrm.Caption = olMailFolder.Name & " - Processing " & i & " of " & olItems.Count
        'oFrm.lblProgress.Width = oFrm.fmeProgress.Width * PortionDone
        SaveMessage olMailItem, sPath
        DoEvents
    Next olMailItem
    'Unload oFrm
lbl_Exit:
    'Set oFrm = Nothing
    Set olItems = Nothing
    Set olMailItem = Nothing
    Exit Sub
err_Handler:
    MsgBox Err.Number & vbCr & Err.Description
    Err.Clear
    GoTo lbl_Exit
End Sub

Private Sub SaveMessage(olItem As MailItem, sPath As String)
'An Outlook macro by Graham Mayor - www.gmayor.com
Dim fname As String

    fname = Format(olItem.ReceivedTime, "yyyymmdd") & Chr(32) & _
            Format(olItem.ReceivedTime, "HH.MM") & " - " & olItem.SenderName & " - " & olItem.Subject
    fname = Replace(fname, Chr(58) & Chr(41), "")
    fname = Replace(fname, Chr(58) & Chr(40), "")
    fname = Replace(fname, Chr(34), "-")
    fname = Replace(fname, Chr(42), "-")
    fname = Replace(fname, Chr(47), "-")
    fname = Replace(fname, Chr(58), "-")
    fname = Replace(fname, Chr(60), "-")
    fname = Replace(fname, Chr(62), "-")
    fname = Replace(fname, Chr(63), "-")
    fname = Replace(fname, Chr(124), "-")
    SaveUnique olItem, sPath, fname
lbl_Exit:
    Exit Sub
End Sub

Private Function SaveUnique(oItem As Object, _
                            strPath As String, _
                            strFileName As String)
'An Outlook macro by Graham Mayor - www.gmayor.com
Dim lngF As Long
Dim lngName As Long
Dim oFSO As Object
    Set oFSO = CreateObject("Scripting.FileSystemObject")

    lngF = 1
    lngName = Len(strFileName)
    Do While oFSO.FileExists(strPath & strFileName & ".rtf") = True
        strFileName = Left(strFileName, lngName) & "(" & lngF & ")"
        lngF = lngF + 1
    Loop
    oItem.SaveAs strPath & strFileName & ".rtf", olRTF
lbl_Exit:
    Set oFSO = Nothing
    Exit Function
End Function

Private Function CreateFolders(strPath As String)
'An Office macro by Graham Mayor - www.gmayor.com
Dim strTempPath As String
Dim lngPath As Long
Dim vPath As Variant
Dim oFSO As Object
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    vPath = Split(strPath, "\")
    strPath = vPath(0) & "\"
    For lngPath = 1 To UBound(vPath)
        strPath = strPath & vPath(lngPath) & "\"
        If Not oFSO.FolderExists(strPath) Then MkDir strPath
    Next lngPath
lbl_Exit:
    Set oFSO = Nothing
    Exit Function
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote