In our company we follow a process where in a team saves e-mails in a shared folder from where people from another team are supposed to pick and start processing. As a improvement idea I was looking for a macro which upon triggering can loop through all the saved e-mails in that folder and can save or bring them in a outlook sub-folder of the processor's inbox of this team.
I have tried and figured out a code from internet which can copy files from one folder to another (please see below) but could not get to modify it to save the .msg files in the outlook subfolder. This is doable manually so was thinking there should be a macro as well which can do it automatically.
Any help will be highly appreciated. Thank you in advance .
Sub Download_sub()
Application.EnableCancelKey = xlDisabled
'downloads the submission mail item into users download folder
Set fobj = CreateObject("Scripting.FileSystemObject") 'create the file system object
fobj.CopyFolder sht_Databases.Range("B21").Value & "\MailFolder" & _
, sht_Databases.Range("B22").Value
Set fobj = Nothing 'release the variable
End Sub
You can use
Application.CreateItemFromTemplate
and pass the folder as the second parameter. Note that the message will be created in the unsent state and no sender properties will be copied.Namespace.OpenSharedItem
to open an MSG file, then copy it to a given folder using MailItem.Move()
.