Preskoči na glavno vsebino

Kako kopirati strukturo map Outlook na namizje (raziskovalec Windows)?

Kot veste, lahko funkcijo arhiviranja uporabimo za kopiranje strukture map v drug Outlook, vendar ali veste, kako kopirati strukturo map Outlooka v določeno okensko mapo, na primer na namizje? Ta članek bo predstavil VBA za enostavno kopiranje strukture map Outlook v raziskovalec Windows.

Kopiranje strukture map Outlook na namizje (raziskovalec Windows)

Zavihek Office – omogočite urejanje in brskanje z zavihki v Microsoft Officeu, kar olajša delo
Kutools za Outlook – izboljšajte Outlook s 100+ naprednimi funkcijami za vrhunsko učinkovitost
Izboljšajte svoj Outlook 2021 - 2010 ali Outlook 365 s temi naprednimi funkcijami. Uživajte v obsežnem 60-dnevnem brezplačnem preizkusu in izboljšajte svojo e-poštno izkušnjo!

Kopiranje strukture map Outlook na namizje (raziskovalec Windows)

Sledite spodnjim korakom, da kopirate strukturo map programa Outlook na namizje ali v raziskovalec Windows.

1. V podoknu za krmarjenje kliknite, da označite določeno mapo, katere strukturo map boste kopirali, in pritisnite druga + F11 za odpiranje okna Microsoft Visual Basic for Applications.

2. klik Orodja > Reference da odprete pogovorno okno Reference. Nato v pogovornem oknu označite Izvajanje Microsoftovih skriptov in kliknite na OK . Oglejte si posnetek zaslona:

3. klik Vstavi > Moduliter kopirajte in prilepite spodnjo kodo VBA v novo okno modula.

VBA: Kopirajte strukturo map programa Outlook v raziskovalec Windows

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. Pritisnite F5 ali kliknite Run za zagon tega VBA.

5. V pojavnem pogovornem oknu Prebrskaj za mapo izberite določeno mapo, v katero boste postavili kopirano strukturo map, in kliknite OK . Oglejte si posnetek zaslona:

Zdaj pojdite v določeno mapo in videli boste, da je struktura mape kopirana na navedeni trdi disk. Oglejte si posnetek zaslona:

Opombe: elementi mape, kot so e-pošta, sestanki, opravila itd., se kopirajo tudi v ustrezne mape na trdem disku.


Povezani članki


Najboljša pisarniška orodja za produktivnost

Kutools za Outlook - Več kot 100 zmogljivih funkcij za nadgradnjo vašega Outlooka

🤖 AI poštni pomočnik: Takojšnja profesionalna e-poštna sporočila z umetno inteligenco – z enim klikom do genialnih odgovorov, popoln ton, večjezično znanje. Preoblikujte pošiljanje e-pošte brez napora! ...

📧 Avtomatizacija e-pošte: Odsoten (na voljo za POP in IMAP)  /  Načrtujte pošiljanje e-pošte  /  Samodejna CC/BCC po pravilih pri pošiljanju e-pošte  /  Samodejno naprej (napredna pravila)   /  Samodejno dodaj pozdrav   /  E-poštna sporočila več prejemnikov samodejno razdeli na posamezna sporočila ...

📨 Email upravljanje: Enostaven priklic e-pošte  /  Blokiraj prevarantska e-poštna sporočila glede na teme in druge  /  Izbriši podvojena e-poštna sporočila  /  napredno iskanje  /  Združite mape ...

📁 Priloge ProShrani paket  /  Batch Detach  /  Paketno stiskanje  /  Samodejno shranite   /  Samodejno loči  /  Samodejno stiskanje ...

🌟 Vmesnik Magic: 😊Več lepih in kul emojijev   /  Povečajte Outlookovo produktivnost s pogledi z zavihki  /  Minimizirajte Outlook, namesto da bi ga zaprli ...

???? Čudeži z enim klikom: Odgovori vsem z dohodnimi prilogami  /   E-poštna sporočila proti lažnemu predstavljanju  /  🕘Pokaži pošiljateljev časovni pas ...

👩🏼‍🤝‍👩🏻 Stiki in koledar: Paketno dodajanje stikov iz izbranih e-poštnih sporočil  /  Razdelite skupino stikov na posamezne skupine  /  Odstranite opomnike za rojstni dan ...

Over 100 Lastnosti Čakajte na svoje raziskovanje! Kliknite tukaj, če želite odkriti več.

 

 

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