I'm working in .NET 3.5, Visual Studio 2010. I'm working on an Outlook Add-In that saves some email into a folder. I've gotten it to work using the Microsoft.Office.Interop.Outlook.MailItem.SaveAs
function. However, the file properties have only the current time (time when the file was exported through the Add-In) as their Date Modified/Date Created etc., and other properties such as To, From, CC, BCC are not there.
If you open a folder in Windows Explorer (I'm using Windows 7), go to the top where it says Name, Date Modified, Type, etc., you can click on More, and see other various columns that might be relevant like "Album Artist", "To", "From", etc.
C# has a really easy way to modify the timings, File.SetCreationTime(filename, DateTime object);
. However, there's no .SetTo or .SetAlbumArtist or anything like that. How would I go about modifying those properties?
Update 1: through research, I found this link: Read/Write 'Extended' file properties (C#), so that might contain the answer...but I have no idea how. The accepted answer mentions running a method on a shell using a .dll. The second answer contains C# code, a commenter then asked basically what I want to know (how to modify the properties of a particular file), and the next commenter responded with "you can't set these"...so I'm still at square 1.
Update 2: I also tried the following:
foreach (Object selectedObject in explorer.Selection)
{
Outlook.MailItem email = (selectedObject as Outlook.MailItem);
//Modify the information about the email
email.To = "I filled in To";
email.SaveAs(filename, OlSaveAsType.olMSG);
}
This code successfully grabs the selected email(s) and save them under filename. However, the email.To = "I filled in To" changes the information when you open the .msg, but not the file properties.