Created
September 26, 2019 09:10
-
-
Save kubadlo/d074ae0c084538ed4d479e6a9c390271 to your computer and use it in GitHub Desktop.
Import *.eml files into any Outlook folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'=================================================================== | |
'Description: VBS script to import eml-files. | |
' | |
'Comment: Before executing the vbs-file, make sure that Outlook is | |
' configured to open eml-files. | |
' Depending on the performance of your computer, you may | |
' need to increase the Wscript.Sleep value to give Outlook | |
' more time to open the eml-file. | |
' Make sure you have enabled "visible" file extensions in explorer.exe | |
' | |
' author : Robert Sparnaaij | |
' contributor: Jakub Leško | |
' version: 1.1 | |
' website: http://www.howto-outlook.com/howto/import-eml-files.htm | |
'=================================================================== | |
Dim objShell : Set objShell = CreateObject("Shell.Application") | |
Dim objFolder : Set objFolder = objShell.BrowseForFolder(0, "Select the folder containing eml-files", 0) | |
Dim Item | |
If (NOT objFolder is Nothing) Then | |
Set WShell = CreateObject("WScript.Shell") | |
Set objOutlook = CreateObject("Outlook.Application") | |
Set Folder = objOutlook.Session.PickFolder | |
If NOT Folder Is Nothing Then | |
For Each Item in objFolder.Items | |
If Right(Item.Name, 4) = ".eml" AND Item.IsFolder = False Then | |
objShell.ShellExecute Item.Path, "", "", "open", 1 | |
' Increase this value in case of import errors | |
WScript.Sleep 200 | |
Set MyInspector = objOutlook.ActiveInspector | |
Set MyItem = objOutlook.ActiveInspector.CurrentItem | |
MyItem.Move Folder | |
End If | |
Next | |
End If | |
End If | |
MsgBox "Import completed.", 64, "Import EML" | |
Set objFolder = Nothing | |
Set objShell = Nothing |
Thank you, was looking for this everywhere. Works beautifully.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked like a charm, thanks!
Important to follow this part in order to work: Make sure you have enabled "visible" file extensions in explorer.exe