Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29919

How to save .MSG file from Outlook VBA and populate the properties "Sender name", "Sender address", "To", "Cc", "Has attachments" and "Priority"?

$
0
0

With Outlook VBA, I want to archive messages in .MSG format after they have been received or sent. All properties of those items are available as long as the items are stored within Outlook.

I can save them as files to the file system in the .MSG format with the MailItem.SaveAs method of Outlook VBA.

I expected that Outlook would populate all properties of the .MSG files correctly with the SaveAs method, but unfortunately, Microsoft has not implemented this and relevant property fields are empty.

There are tools like MessageSave that populate those properties correctly in the .MSG file format so that they are shown in File Explorer. See MessageSave Screenshots

But I need to do this in Outlook VBA and I am now looking for a way to set the properties of those .MSG files after saving the files, so that the values are shown in Windows File Explorer when the user shows those properties as columns in the Details View.

Here was a similar question a few years ago and the answers recommended the use of DSOFile - see How to save Outlook mails as .msg file with categories and other details?

With DSOFile I can only update some of the properties of the .MSG file, but not all that are required:

DSOFile can set a pre-defined list of SummaryProperties or additionalCustomProperties. Only the following nine SummaryProperties can be set with DSOFile: Author, Category, Comments, Company, Keywords, LastSavedBy, Manager, Subject and Title.

The properties "Sender name", "Sender address", "To", "Cc", "Has attachments" and "Priority" are not in the list of the SummaryProperties of DSOFile.

Those properties are shown in File Explorer in the list of available properties in the "Choose Details" dialog and also need to be populated correctly.

I tried to set them with DSOFile as CustomProperties , but the values are not shown in the columns of File Explorer.

Conclusion: In SummaryProperties of DSOFile not all required properties are available and CustomProperties is not the correct method.

How can I set all properties in VBA if DSOFile cannot do it or is there an alternative method to save a mail item in .MSG format with all properties set correctly so that they show up in the columns of the Details View in File Explorer ?


Viewing all articles
Browse latest Browse all 29919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>