I am trying to use an xml file to determine which outlook properties be should be included in a workflow executed via VSTO addin code.
Example
The xml might state that the Subject
of the current Outlook.MailItem
is required by the workflow. I haven't been able to use reflection to get the Subject
property using its string name "Subject" because the MailItem
is an interface and not a class.
I thought the solution might be to create and compile dynamic C# code that returns the required property by name...
Problem: I have been unable to work out how to find the location of the running Microsoft.Office.Interop.Outlook.dll so that I can add it as a reference to the dynamic compiler. I have tried a number of combinations, the last effort is shown below.
CodeDomProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = false;
parameters.GenerateInMemory = true;
parameters.IncludeDebugInformation = false;
parameters.ReferencedAssemblies.Add(Assembly.GetAssembly(typeof(Outlook.MailItem)).Location);