none
How to set file details using VBA RRS feed

  • Question

  • In Windows Explorer, in addition to the standard Filename, Date Created, File Size, columns, there are many additional columns that can be added as well, such as "From", "To", "Author", "Bitrate", "Resolution", etc. I want to be able to set the value of some of these fields. Specifically, I am saving Outlook items - messages, appointments, contacts - as individual files and I want to be able to see in Windows Explorer these additional fields as appropriate (don't ask why, it's just what I need to do).

    The code to save the files is working fine, but the "To", "From", and other fields are empty. How do I do set them? I would have thought that they'd be set automatically just by using the Save method of the message object, but no.

    I tried using the FileSystemObject to set Attributes and Properties, but the fields I'm looking for are not there.

    Saving the message from Outlook interface does not set these fields either - there is a MyMessage.msg file, but the "To", "From" fields are empty.

    I've used dsoFile, but these are not one of the standard properties or attributes. I've created a custom property called "To", (which was successful, in that the custom property stuck and I can see it when I right click on the file and look up custom properties), but it will not show in Windows Explorer in the "To" column.

    Any assistance appreciated.


    • Edited by Quercus47 Wednesday, October 12, 2016 8:30 PM
    Wednesday, October 12, 2016 8:26 PM

Answers

  • With VBA (DSOFile) you can only set basic file properties and only on NTFS. Microsoft has discontinued the practice of storing file properties in the secondary NTFS stream (introduced with Windows Vista) as properties saved on those streams do not travel with the file when the file is send as attachment or stored on USB disk that is FAT32 not NTFS.

    Starting with Windows you have to use custom file Properties handlers to retrieve and set information and in my knowledge you can not do this with VBA. Those Property handlers are invoked by the application responsible/registered to handle the particular file type. Those properties are stored with the file (in the file content as bytes within the file not as property on the file system) so they preserved no matter what file system is the file resides on. Perfect example is the JPG file - any properties like camera used/ lenses etc is stored as external information in the file it self, alongside the image bytes. JPG format/standard allows EXIF (External information), but MSG files/format does not.

    Just because you are seeing TO/FROM/CC in the list of file properties to enable with explorer it does not mean that there is default property handler that will extract or save this information - this certainly is not possible for the MSG files as they are very simple text files with no space/place to set or read from this kind of information. Microsoft created GUIDs/ProgramIDs for almost any property they can think of (including Mail message properties) but there are no default handlers for those Mail message properties  (and many others that are simply reserved by name/programId) .

    You can write your own Property handler and register it with Windows to extract the FROM/TO/CC/BCC fields from MSG files (search internet on how to open and edit MSG for plethora of examples on how to read MSG) but you wont be able to save them as you will break the MSG content format.

    Sorry this is not the answer you are expecting. I would suggest you do more reading on property handlers for further help if you decide to go with creating your own property handler.

    • Marked as answer by Quercus47 Thursday, October 13, 2016 11:47 AM
    Thursday, October 13, 2016 3:41 AM

All replies

  • The properties you are looking for are not properties of the file it self - they are properties of the content of the file. You can not resave those properties without actually parsing the content into mail object which you can change and resave as msg file if the client/classes or whatever else may be that you are using for Mail object parsing can do this.
    Wednesday, October 12, 2016 8:31 PM
  • I'm sorry but I don't understand what you are getting at. Is there a code example that will help point me in the right direction, or a tech article that describes this in more detail?
    Wednesday, October 12, 2016 9:45 PM
  • With VBA (DSOFile) you can only set basic file properties and only on NTFS. Microsoft has discontinued the practice of storing file properties in the secondary NTFS stream (introduced with Windows Vista) as properties saved on those streams do not travel with the file when the file is send as attachment or stored on USB disk that is FAT32 not NTFS.

    Starting with Windows you have to use custom file Properties handlers to retrieve and set information and in my knowledge you can not do this with VBA. Those Property handlers are invoked by the application responsible/registered to handle the particular file type. Those properties are stored with the file (in the file content as bytes within the file not as property on the file system) so they preserved no matter what file system is the file resides on. Perfect example is the JPG file - any properties like camera used/ lenses etc is stored as external information in the file it self, alongside the image bytes. JPG format/standard allows EXIF (External information), but MSG files/format does not.

    Just because you are seeing TO/FROM/CC in the list of file properties to enable with explorer it does not mean that there is default property handler that will extract or save this information - this certainly is not possible for the MSG files as they are very simple text files with no space/place to set or read from this kind of information. Microsoft created GUIDs/ProgramIDs for almost any property they can think of (including Mail message properties) but there are no default handlers for those Mail message properties  (and many others that are simply reserved by name/programId) .

    You can write your own Property handler and register it with Windows to extract the FROM/TO/CC/BCC fields from MSG files (search internet on how to open and edit MSG for plethora of examples on how to read MSG) but you wont be able to save them as you will break the MSG content format.

    Sorry this is not the answer you are expecting. I would suggest you do more reading on property handlers for further help if you decide to go with creating your own property handler.

    • Marked as answer by Quercus47 Thursday, October 13, 2016 11:47 AM
    Thursday, October 13, 2016 3:41 AM
  • Thank you for the explanation. True... not the answer I was hoping for, but at least I understand the problem much better now.
    Thursday, October 13, 2016 11:47 AM