Vai al contenuto principale

Come copiare la struttura delle cartelle di Outlook sul desktop (Windows Explorer)?

Come sai, possiamo applicare la funzione Archivio per copiare la struttura delle cartelle su un altro Outlook, ma sai come copiare la struttura delle cartelle di Outlook in una determinata cartella della finestra, come il desktop? Questo articolo introdurrà un VBA per copiare facilmente la struttura delle cartelle di Outlook in Windows Explorer.

Copia la struttura delle cartelle di Outlook sul desktop (Windows Explorer)

Scheda Office: abilita la modifica e la navigazione a schede in Microsoft Office, rendendo il lavoro un gioco da ragazzi
Kutools per Outlook: potenzia Outlook con oltre 100 funzionalità avanzate per un'efficienza superiore
Potenzia il tuo Outlook 2021-2010 o Outlook 365 con queste funzionalità avanzate. Goditi una prova gratuita completa di 60 giorni e migliora la tua esperienza di posta elettronica!

Copia la struttura delle cartelle di Outlook sul desktop (Windows Explorer)

Seguire i passaggi seguenti per copiare la struttura delle cartelle di Outlook sul desktop o su Windows Explorer.

1. Nel riquadro di spostamento, fare clic per evidenziare la cartella specificata di cui si copierà la struttura di cartelle e premere altro + F11 tasti per aprire la finestra di Microsoft Visual Basic, Applications Edition.

2. Clic Strumenti > Riferimenti per aprire la finestra di dialogo Riferimenti. Quindi nella finestra di dialogo seleziona il file Runtime di script Microsoft opzione e fare clic su OK pulsante. Vedi screenshot:

3. Clic inserire > Modulie copia e incolla sotto il codice VBA nella nuova finestra del modulo.

VBA: copia la struttura delle cartelle di Outlook in Windows Explorer

Dim xFSO As Scripting.FileSystemObject
Sub CopyOutlookFldStructureToWinExplorer()
    ExportAction "Copy"
End Sub
  
Sub ExportAction(xAction As String)
Dim xFolder As Outlook.Folder
Dim xFldPath As String
xFldPath = SelectAFolder()
If xFldPath = "" Then
    MsgBox "You did not select a folder. Export cancelled.", vbInformation + vbOKOnly, "Kutools for Outlook"
Else
    Set xFSO = New Scripting.FileSystemObject
    Set xFolder = Outlook.Application.ActiveExplorer.CurrentFolder
    ExportOutlookFolder xFolder, xFldPath
End If
Set xFolder = Nothing
Set xFSO = Nothing
End Sub

Sub ExportOutlookFolder(ByVal OutlookFolder As Outlook.Folder, xFldPath As String)
Dim xSubFld As Outlook.Folder
Dim xItem As Object
Dim xPath As String
Dim xFilePath As String
Dim xSubject As String
Dim xCount As Integer
Dim xFilename As String
On Error Resume Next
xPath = xFldPath & "\" & OutlookFolder.Name
'?????????,??????
If Dir(xPath, 16) = Empty Then MkDir xPath
For Each xItem In OutlookFolder.Items
    xSubject = ReplaceInvalidCharacters(xItem.Subject)
    xFilename = xSubject & ".msg"
    xCount = 0
    xFilePath = xPath & "\" & xFilename
    If xFSO.FileExists(xFilePath) Then
        xCount = xCount + 1
        xFilename = xSubject & " (" & xCount & ").msg"
        xFilePath = xPath & "\" & xFilename
    End If
    xItem.SaveAs xFilePath, olMSG
Next
For Each xSubFld In OutlookFolder.Folders
    ExportOutlookFolder xSubFld, xPath
Next
Set OutlookFolder = Nothing
Set xItem = Nothing
End Sub

Function SelectAFolder() As String
Dim xSelFolder As Object
Dim xShell As Object
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xSelFolder = xShell.BrowseForFolder(0, "Select a folder", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
    SelectAFolder = xSelFolder.self.Path
End If
Set xSelFolder = Nothing
Set xShell = Nothing
End Function
  
Function ReplaceInvalidCharacters(Str As String) As String
Dim xRegEx
Set xRegEx = CreateObject("vbscript.regexp")
xRegEx.Global = True
xRegEx.IgnoreCase = False
xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
ReplaceInvalidCharacters = xRegEx.Replace(Str, "")
End Function

4. Stampa F5 o fare clic su Correre pulsante per eseguire questo VBA.

5. Nella finestra di dialogo Sfoglia per cartelle, selezionare la cartella specificata in cui inserire la struttura della cartella copiata e fare clic su OK pulsante. Vedi screenshot:

Ora vai alla cartella specificata, vedrai la struttura della cartella copiata sul disco rigido specificato. Vedi screenshot:

Note:: anche gli elementi della cartella, come e-mail, appuntamenti, attività, ecc. vengono copiati nelle cartelle corrispondenti del disco rigido.


Articoli Correlati


I migliori strumenti per la produttività in ufficio

Kutools for Outlook - Oltre 100 potenti funzionalità per potenziare il tuo Outlook

🤖 Assistente di posta AI: E-mail istantanee professionali con la magia dell'intelligenza artificiale: risposte geniali con un solo clic, tono perfetto, padronanza multilingue. Trasforma l'e-mail senza sforzo! ...

???? Automazione di posta elettronica: Fuori sede (disponibile per POP e IMAP)  /  Pianifica l'invio di e-mail  /  CC/BCC automatico in base alle regole durante l'invio di e-mail  /  Inoltro automatico (regole avanzate)   /  Aggiunta automatica di saluto   /  Suddividi automaticamente le email con più destinatari in singoli messaggi ...

📨 gestione e-mail: Richiama facilmente le email  /  Blocca le email truffe per soggetto e altri  /  Elimina email duplicate  /  Ricerca avanzata  /  Consolidare cartelle ...

📁 Allegati ProSalvataggio in batch  /  Stacca batch  /  Comprimi in lotti  /  Salvataggio automatico   /  Scollegamento automatico  /  Comprimi automaticamente ...

🌟 Magia dell'interfaccia: 😊Più emoji carini e fantastici   /  Aumenta la tua produttività in Outlook con le visualizzazioni a schede  /  Riduci a icona Outlook invece di chiuderlo ...

👍 Meraviglie con un clic: Rispondi a tutti con gli allegati in arrivo  /   E-mail anti-phishing  /  🕘Mostra il fuso orario del mittente ...

👩🏼‍🤝‍👩🏻 Contatti e calendario: Aggiungi in batch contatti dalle email selezionate  /  Dividere un gruppo di contatti in singoli gruppi  /  Rimuovi promemoria compleanno ...

Al di sopra Caratteristiche 100 Attendi la tua esplorazione! Clicca qui per scoprire di più.

 

 

Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello, that's brilliant! How can I adjust the code to only save email attachments, not the entire message? Many thanks
This comment was minimized by the moderator on the site
'This code solves the duplicate filename problemDim xFSO As Scripting.FileSystemObject
Sub CopyOutlookFldStructureToWinExplorer()
ExportAction "Copy"
End Sub

Sub ExportAction(xAction As String)
Dim xFolder As Outlook.Folder
Dim xFldPath As String
xFldPath = SelectAFolder()
If xFldPath = "" Then
MsgBox "You did not select a folder. Export cancelled.", vbInformation + vbOKOnly, "Kutools for Outlook"
Else
Set xFSO = New Scripting.FileSystemObject
Set xFolder = Outlook.Application.ActiveExplorer.CurrentFolder
ExportOutlookFolder xFolder, xFldPath
End If
Set xFolder = Nothing
Set xFSO = Nothing
End Sub

Sub ExportOutlookFolder(ByVal OutlookFolder As Outlook.Folder, xFldPath As String)
Dim xSubFld As Outlook.Folder
Dim xItem As Object
Dim xPath As String
Dim xFilePath As String
Dim xSubject As String
Dim xCount As Integer
Dim xFilename As String
On Error Resume Next
xPath = xFldPath & "\" & OutlookFolder.Name
'?????????,??????
If Dir(xPath, 16) = Empty Then MkDir xPath

xCount = 0

For Each xItem In OutlookFolder.Items
xSubject = ReplaceInvalidCharacters(xItem.Subject)
xFilename = xSubject & ".msg"
xFilePath = xPath & "\" & xFilename
If xFSO.FileExists(xFilePath) Then
xCount = xCount + 1
xFilename = xSubject & " (" & xCount & ").msg"
xFilePath = xPath & "\" & xFilename
While xFSO.FileExists(xFilePath)
xCount = xCount + 1
xFilename = xSubject & " (" & xCount & ").msg"
xFilePath = xPath & "\" & xFilename
Wend
End If
xItem.SaveAs xFilePath, olMSG
xCount = 0
Next
For Each xSubFld In OutlookFolder.Folders
ExportOutlookFolder xSubFld, xPath
Next
Set OutlookFolder = Nothing
Set xItem = Nothing
End Sub

Function SelectAFolder() As String
Dim xSelFolder As Object
Dim xShell As Object
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xSelFolder = xShell.BrowseForFolder(0, "Select a folder", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
SelectAFolder = xSelFolder.self.Path
End If
Set xSelFolder = Nothing
Set xShell = Nothing
End Function

Function ReplaceInvalidCharacters(Str As String) As String
Dim xRegEx
Set xRegEx = CreateObject("vbscript.regexp")
xRegEx.Global = True
xRegEx.IgnoreCase = False
xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
ReplaceInvalidCharacters = xRegEx.Replace(Str, "")
End Function
This comment was minimized by the moderator on the site
Here is how i modified the code to make it work

i will paste it in reply
This comment was minimized by the moderator on the site
Dim xFSO As Scripting.FileSystemObject
Sub CopyOutlookFldStructureToWinExplorer()
ExportAction "Copy"
msg = MsgBox("Copy of your Inbox is successful", vbOKOnly, "Done")
End Sub

Sub ExportAction(xAction As String)
Dim xFolder As Outlook.Folder
Dim xFldPath As String
xFldPath = SelectAFolder()
If xFldPath = "" Then
MsgBox "You did not select a folder. Export cancelled.", vbInformation + vbOKOnly, "Kutools for Outlook"
Else
Set xFSO = New Scripting.FileSystemObject
Set xFolder = Outlook.Application.ActiveExplorer.CurrentFolder
ExportOutlookFolder xFolder, xFldPath
End If
Set xFolder = Nothing
Set xFSO = Nothing
End Sub

Sub ExportOutlookFolder(ByVal OutlookFolder As Outlook.Folder, xFldPath As String)
Dim xSubFld As Outlook.Folder
Dim xItem As Object
Dim xPath As String
Dim xFilePath As String
Dim xSubject As String * 100

Dim xCounter As Integer
Dim xFilename As String
Dim xFileDateRec As String

On Error Resume Next
xPath = xFldPath & "\" & ReplaceInvalidCharacters(OutlookFolder.Name)

If Dir(xPath, 16) = Empty Then MkDir xPath
xCounter = 0

For Each xItem In OutlookFolder.Items
xCounter = xCounter + 1
xSubject = ReplaceInvalidCharacters(xItem.Subject)
xFileDateRec = xItem.ReceivedTime
xFilename = ReplaceInvalidCharacters(RTrim(xSubject) & xFileDateRec & " " & xCounter & ".msg")
xFilePath = xPath & "\" & xFilename
xItem.SaveAs xFilePath, olMSG
Next
For Each xSubFld In OutlookFolder.Folders
ExportOutlookFolder xSubFld, xPath
Next
Set OutlookFolder = Nothing
Set xItem = Nothing
End Sub

Function SelectAFolder() As String
Dim xSelFolder As Object
Dim xShell As Object
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xSelFolder = xShell.BrowseForFolder(0, "Select a folder", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
SelectAFolder = xSelFolder.self.Path
End If
Set xSelFolder = Nothing
Set xShell = Nothing
End Function

Function ReplaceInvalidCharacters(Str As String) As String
Dim xRegEx
Set xRegEx = CreateObject("vbscript.regexp")
xRegEx.Global = True
xRegEx.IgnoreCase = False
xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
ReplaceInvalidCharacters = xRegEx.Replace(Str, "_")
End Function
This comment was minimized by the moderator on the site
If I re-run this VBA every couple months, does it only copy new email or does it copy new email and create duplicates for all existing emails?
This comment was minimized by the moderator on the site
xItem.SaveAs xFilePath, olMSG
Next
For Each xSubFld In OutlookFolder.Folders
ExportOutlookFolder xSubFld, xPath
Next
Set OutlookFolder = Nothing
Set xItem = Nothing
End Sub

Function SelectAFolder() As String
Dim xSelFolder As Object
Dim xShell As Object
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xSelFolder = xShell.BrowseForFolder(0, "Select a folder", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
SelectAFolder = xSelFolder.self.Path
End If
Set xSelFolder = Nothing
Set xShell = Nothing
End Function

Function ReplaceInvalidCharacters(Str As String) As String
Dim xRegEx
Set xRegEx = CreateObject("vbscript.regexp")
xRegEx.Global = True
xRegEx.IgnoreCase = False
xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
ReplaceInvalidCharacters = xRegEx.Replace(Str, "_")
End Function
This comment was minimized by the moderator on the site
What is this second piece of code? Do I use the original reply code or the second reply and that?
This comment was minimized by the moderator on the site
it is all 1 code, it was too long to post in 1 piece
This comment was minimized by the moderator on the site
hello, same thing. you code works great.. the only thing is that the duplicate names, more than (1), are not exported.
Please add the option.
This comment was minimized by the moderator on the site
Yes! the same as Ammar asked, can you modify the code so it copies every item even if it has the same name!!! this would help me a lot
This comment was minimized by the moderator on the site
Hello I have one question, I used the above mentioned code, but it is missing the related conversations as it has the same subject. This is created problem as the numbers of items in outlook not matching with number of items in folder. Can you please help to edit the above code so that it also paste all the items even though it has same subject ?
This comment was minimized by the moderator on the site
Dim xFSO As Scripting.FileSystemObject
Sub CopyOutlookFldStructureToWinExplorer()
ExportAction "Copy"
End Sub

Sub ExportAction(xAction As String)
Dim xFolder As Outlook.Folder
Dim xFldPath As String
xFldPath = SelectAFolder()
If xFldPath = "" Then
MsgBox "You did not select a folder. Export cancelled.", vbInformation + vbOKOnly, "Kutools for Outlook"
Else
Set xFSO = New Scripting.FileSystemObject
Set xFolder = Outlook.Application.ActiveExplorer.CurrentFolder
ExportOutlookFolder xFolder, xFldPath
End If
Set xFolder = Nothing
Set xFSO = Nothing
End Sub

Sub ExportOutlookFolder(ByVal OutlookFolder As Outlook.Folder, xFldPath As String)
Dim xSubFld As Outlook.Folder
Dim xItem As Object
Dim xPath As String
Dim xFilePath As String
Dim xSubject As String
Dim xCount As Integer
Dim xFilename As String
On Error Resume Next
xPath = xFldPath & "\" & OutlookFolder.Name
'?????????,??????
If Dir(xPath, 16) = Empty Then MkDir xPath
xCount = 0 ' Pasted lineFor Each xItem In OutlookFolder.Items
xSubject = ReplaceInvalidCharacters(xItem.Subject)
xFilename = xSubject & ".msg"
' Deleted line xCount = 0
xFilePath = xPath & "\" & xFilename
If xFSO.FileExists(xFilePath) Then
xCount = xCount + 1
xFilename = xSubject & " (" & xCount & ").msg"
xFilePath = xPath & "\" & xFilename
Else ' New linexCount = 0 ' New line E xItem.SaveAs xFilePath, olMSG
Next
For Each xSubFld In OutlookFolder.Folders
ExportOutlookFolder xSubFld, xPath
Next
Set OutlookFolder = Nothing
Set xItem = Nothing
End Sub

Function SelectAFolder() As String
Dim xSelFolder As Object
Dim xShell As Object
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xSelFolder = xShell.BrowseForFolder(0, "Select a folder", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
SelectAFolder = xSelFolder.self.Path
End If
Set xSelFolder = Nothing
Set xShell = Nothing
End Function

Function ReplaceInvalidCharacters(Str As String) As String
Dim xRegEx
Set xRegEx = CreateObject("vbscript.regexp")
xRegEx.Global = True
xRegEx.IgnoreCase = False
xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
ReplaceInvalidCharacters = xRegEx.Replace(Str, "")
End Function
This comment was minimized by the moderator on the site
This is great, thank you! What would the code look like if I just want Inbox + all subfolders? (i.e., exclude deleted items?)Thank you!Morghan
This comment was minimized by the moderator on the site
It works (sort of), but (a) there were more messages exported to one folder than were in the corresponding Outlook Folder and (b) there were fewer messages exported to one folder than were in the Outlook Folder and (c) (not 100% sure) I think one message went to the wrong folder.
This comment was minimized by the moderator on the site
I have Outlook 15, and the macro won't replace the "/" where used in Outlook folder names. It just skips those folders. Is this a compatibility issue?
This comment was minimized by the moderator on the site
Bonjour,

Serait-il possible de stocker les mails dans un fichier .pst ?

D'avance merci pour vos retours.

Cordialement,

Ando Rakotomalala
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations