This function gets the parent PropertyPageSite
Object using Reflection. It must be called in Load event.
Visual Basic
Private Function GetPropertyPageSite() As Outlook.PropertyPageSite
Dim objType As Type = GetType(System.Object)
Dim assemblyPath As String = objType.Assembly.CodeBase.Replace("mscorlib.dll", "System.Windows.Forms.dll").Replace("file:///", "")
Dim assemblyName As String = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath).FullName
Dim unsafeNativeMethods As Type = Type.[GetType](System.Reflection.Assembly.CreateQualifiedName(assemblyName, "System.Windows.Forms.UnsafeNativeMethods"))
Dim oleObjectType As Type = unsafeNativeMethods.GetNestedType("IOleObject")
Dim methodInfo As System.Reflection.MethodInfo = oleObjectType.GetMethod("GetClientSite")
Dim propertyPageSite As Object = methodInfo.Invoke(Me, Nothing)
Return DirectCast(propertyPageSite, Outlook.PropertyPageSite)
End Function
CSharp
private Outlook.PropertyPageSite GetPropertyPageSite()
{
Type objType = typeof(System.Object);
string assemblyPath = objType.Assembly.CodeBase.Replace("mscorlib.dll", "System.Windows.Forms.dll").Replace("file:///", "");
string assemblyName = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath).FullName;
Type unsafeNativeMethods = Type.GetType(System.Reflection.Assembly.CreateQualifiedName(assemblyName, "System.Windows.Forms.UnsafeNativeMethods"));
Type oleObjectType = unsafeNativeMethods.GetNestedType("IOleObject");
System.Reflection.MethodInfo methodInfo = oleObjectType.GetMethod("GetClientSite");
Object propertyPageSite = methodInfo.Invoke(this, null);
return (Outlook.PropertyPageSite)propertyPageSite;
}
From How to implement OL PropertyPage / Customize Outlook Options Dialog