vbaoutlookoutlook-2007pst

Programmatically add a .MSG file to an outlook folder


I am attempting to create a PST with a sample of MSGs.

Rather than dragging and dropping into the desired folders, does the Outlook.MAPIFolder in (VBA) provide a way to add a .MSG file from the file system into an Outlook folder (I do not want to recreate the MSG, something akin to drag and drop into a folder).

My simple use case is

  1. I have a file someEmail.msg on my local file system in a folder say c:/someLocalFileSystemFolder

  2. In Outlook I have a pst folder say somePSTFolder

  3. I want to import someEmail.msg into somePSTFolder such that the structure is

    somPSTFolder
    + someLocalFileSystemFolder
    + + someEmail.msg

I have managed to recreate my local file system folder structure into the pst folder structure using VBA. Is it possible to import msgs programmatically?


Solution

  • Consider using the .Move method, documented here:

    http://msdn.microsoft.com/en-us/library/office/ff860683(v=office.15).aspx

    Whether the message is re-created, I am not certain. If so, you could always simply delete it from the source if you no longer need it.