Office automation - getting a built-in constant with late binding

   Hi everyone,

   I'm using late binding to access Office applications. I don't want to hardcoding the constants (for example Outlook.OlItemType.olMailItem) but to get them at run time by using reflection. Here it is a bit of code:

Type outlookType;

outlookType = Type.GetTypeFromProgID("Outlook.Application");

outlookApplication = Activator.CreateInstance(outlookType);

parameters = new object[1];

parameters[0] = 0; //instead of 0 i would like to get the Outlook.OlItemType.olMailItem constant with Reflection

outlookMessage = outlookApplication.GetType().InvokeMember( "CreateItem",

BindingFlags.InvokeMethod, null, outlookApplication, parameters );

   Has somebody an idea how to do it

   Best Regards,

   Gabriela



Answer this question

Office automation - getting a built-in constant with late binding