How to import many msg into different public folders in Outlook

Status
Not open for further replies.

jmp917

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
I have a number of messages stored on an external drive in different directories. I would like to script to import say directory "ABC" into Public folder "ABC" in Outlook.
Manual drag and drop would take forever. I am hoping someone has encountered this situation before and can share their resolution?
 
Should be able to drag multiple messages and drop them in the folder - but if that doesn't work, I have a macro.

 
Should be able to drag multiple messages and drop them in the folder - but if that doesn't work, I have a macro.

Yes, and thank you, the drag and drop would work also the macro you were kind enough to provide would too...unfortunately due to an error I made, there are almost 200 public folders I need to "repopulate" from the external storage.
I was hoping for a method where I might map directory to public folder and systematically have the msg copied into the public folder. Thanks again I may have to just use a single folder at a time update.
 
Oh... I'm not aware of a method you could use to automate it.

If the paths are the same, save for the last folder, a macro could do all at once, but will be slow (as you probably expect, with 200 folders)

You need to tweak it so you use the parent path then get the subfolder under it to set the source - replacing these lines
SourceFolderName = "C:\Users\drcp\Documents\Email\"
Set SourceFolder = fso.GetFolder(SourceFolderName)

This can be changed to use the public folder tree - the final folder name can be the same as the subfolder from sourcefolder.
Set Savefolder = Session.GetDefaultFolder(olFolderInbox).Folders("My Subfolder")
 
Oh... I'm not aware of a method you could use to automate it.

If the paths are the same, save for the last folder, a macro could do all at once, but will be slow (as you probably expect, with 200 folders)

You need to tweak it so you use the parent path then get the subfolder under it to set the source - replacing these lines
SourceFolderName = "C:\Users\drcp\Documents\Email\"
Set SourceFolder = fso.GetFolder(SourceFolderName)

This can be changed to use the public folder tree - the final folder name can be the same as the subfolder from sourcefolder.
Set Savefolder = Session.GetDefaultFolder(olFolderInbox).Folders("My Subfolder")
wow and thanks so much for replying so quickly.
If I understand correctly if the image below is the files?
1633097300875.png

and I make the change in the macro as :

'Source folder
SourceFolderName = "C:\TestMsg"
Set SourceFolder = fso.GetFolder(SourceFolderName)

'Set the Outlook folder name
' Set Savefolder = Session.GetDefaultFolder(olFolderInbox).Folders("TestMsg")
Set Savefolder = Application.ActiveExplorer.CurrentFolder

and my Public folder tree in Outlook looks like:

Public Folders
All Public Folders
1633097410312.png


I would highlight the TestMsg and run the Macro you have created?
 
Well in testing it only copies over into TstMsg...I am missing something I'll continue to test
 
Well in testing it only copies over into TstMsg...I am missing something I'll continue to test
Well I've tested a lot and it seems that. I have included the Macro as I have configured..if there is anything that you see I should change? Thank you.

Sub ImportMessagesInFolder()
Dim fso As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder
Dim SourceFolderName As String
Dim FileItem As Scripting.File
Dim strFile, strFileType As String
Dim oMsg As Object
Dim copiedMsg As MailItem
Dim Savefolder As Outlook.Folder

Set fso = New Scripting.FileSystemObject
'Source folder
SourceFolderName = "C:\TestMsg"
Set SourceFolder = fso.GetFolder(SourceFolderName)

'Set the Outlook folder name
' Set Savefolder = Session.GetDefaultFolder(olFolderInbox).Folders("TestMsg")
Set Savefolder = Application.ActiveExplorer.CurrentFolder

For Each FileItem In SourceFolder.Files

Set oMsg = Session.OpenSharedItem(FileItem.Path)
On Error Resume Next

Set copiedMsg = oMsg.Copy
copiedMsg.Move Savefolder

Set copiedMsg = Nothing
oMsg.Delete
Set oMsg = Nothing

Next FileItem

Set FileItem = Nothing
Set SourceFolder = Nothing
Set fso = Nothing

End Sub
 
two issues - this is the current folder open in outlook - so it will work to do one folder at a time - select the folder in outlook, make sure the macro uses the right folder in the folder system (SourceFolderName = "C:\TestMsg\A") and run it. rinse, repeat on each folder. Slow, but it works. This might actually be better of you have a lot of messages in each folder because the entire system won't be tied up as it is moving all of the messages - you can do a folder in between doing other things.

'Set the Outlook folder name
' Set Savefolder = Session.GetDefaultFolder(olFolderInbox).Folders("TestMsg")
Set Savefolder = Application.ActiveExplorer.CurrentFolder

this should use parent folder under the PF -
Set Savefolder = Session.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("TestMsg") .folders("name")



Working with VBA and non-default Outlook Folders



to work through all folders at one, you need to use a function that gets the subfolders - this one is not the best example for your needs, but it shows how to walk all folders. I'm pretty sure I have a better example, if I can find it.

You would also need the code for to walk the folder on the hard drive - I'm sure there are some fso (file system object) samples on the web - referencing Excel, but the fso code will work with outlook too.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
C New pc, new outlook, is it possible to import auto-complete emailaddress Using Outlook 4
T How to Export & Import GMAIL Contacts into Outlook 2021 ? Using Outlook 4
W Outlook 365 File access denied attempting to import .pst Using Outlook 6
S Import PST to Office 365 Using Outlook 1
C How to import Outlook calendar? Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
K Disabling import/export button to restrict PST creation Using Outlook 3
I Outlook 365 - import/attach PST file that used POP3 Using Outlook.com accounts in Outlook 0
M Export-Import .pst file problems Using Outlook 2
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
CWM550 Import Exchange Server Administration 1
R PST->Outlook.com (Import vs Drag-n-Drop methods Using Outlook.com accounts in Outlook 2
DoctorJellybean Import accounts\files Using Outlook 1
S Import contacts to a shared mailbox Outlook VBA and Custom Forms 2
P Import Categories from Outlook 2003 Using Outlook 8
avant-guvnor Import csv problem Using Outlook 7
T Outlook 2016 CSV Translator Import Error Using Outlook 6
Rupert Dragwater How to import contact list Using Outlook 15
C Import Outlook 2016 contacts into to: field Using Outlook 1
P Import an .ics file to a specific calendar Using Outlook 4
L Need to import multiple Outlook files to Office 365 Account Using Outlook 4
R ost file import Using Outlook 2
T Outlook Calendar 2016 import Excel Using Outlook 1
I Import Office theme .thmx Using Outlook 4
Diane Poremsky Batch Import Photos into Outlook Contacts Using Outlook 0
Diane Poremsky Can't import CSV or move Outlook items into EAS Accounts Using Outlook 0
Diane Poremsky How to Import Appointments into a Group Calendar Using Outlook 0
B Import Excel Text into Outlook Calender Using Outlook 4
M How to Import YES/NO Checkboxes? BCM (Business Contact Manager) 0
J Converted .ost to .pst: Want to Import and Reconnect with IMAP Email Account Using Outlook 2
GregS Import from Outlook.com .ost to IMAP .pst? Using Outlook 3
Q Outlook 2016\365 export specific rules to import in another system Exchange Server Administration 1
Diane Poremsky Macro to Bulk Import Contacts and vCards into Outlook Using Outlook 0
Diane Poremsky Import Images into the Active Directory Using Outlook 0
M convert/import a customized record into the default "Account" record BCM (Business Contact Manager) 0
Diane Poremsky Macro to Bulk Import vCards into Outlook Using Outlook 0
e_a_g_l_e_p_i question about saving my .pst so I can import it to my Outlook after I build a new system Using Outlook 10
V Import from Outlook 2013 ost file? Using Outlook 2
ogodt Change Default contact form and import from Excel 2010 Using Outlook 1
E Want to Import Outlook 2003 pst files to later version Using Outlook 6
A Does Outlook import Gmail Archive? Using Outlook 1
E PDF Import Using Outlook 1
B Problem with import Excel BCM (Business Contact Manager) 1
bhogesh How to import .htm saved mail to outlook Using Outlook 3
J Easy way to re-import Gmail folders/labels into Outlook? Using Outlook 9
J Opening/Archiving/Import/Export PST files Using Outlook 4
Calvyn Outlook 2003 cannot import .vcs subject Using Outlook 1
R How to Import Exchange Calendar data to Outlook.com Calendar Using Outlook.com accounts in Outlook 11

Similar threads

Back
Top