Help with Outlook Object Model Guard...

Hi,
I've always had problems accessing an AppointmentItem body...and someone pointed me this:

http://msdn2.microsoft.com/en-us/library/1thd35d7(vs.80).aspx

However, I've this scenario:

first of all, I'm accessing to the AppointmentItems from another class, which is not the ThisApplication (and it's not in the same library --> it's another C# project). Second, instead of create an item,I've to READ the items...this is the cycle I'm used to make:

foreach (object o in remoteCalendar.Folder.Items)
{
AppointmentItem appointment = o as AppointmentItem;
...
}
I tried something stupid like creating an Appointement as described by the documentation, pass it to the "Controller" class and then just making

_appointmentFromDoc = appointment;

But it didn't work...
How should I change my code in order to get read access to the AppointementItem.Body property
Should I cross-reference the 2 projects (The VSTO project contains a reference to the "Controller" project...should the "Controller" project contain a reference to the VSTO project )
Thank you

LastHope



Answer this question

Help with Outlook Object Model Guard...

  • Andreas Wickman

    Hi,
    could you be more clear Because I didn't understand...
    In the class that derives from the VSTO plugin what kind of Application object should I pass
    Example:

    Controller cont = new Controller(this);

    But, in this case, I should also edit the references of the Controller class (in that project I've got two Application classes:
    System.Windows.Form.Application
    Microsoft.Interop.Office.Outlook.Application)
    But the "this" object is different from a Microsoft.Interop.Office.Outlook.Application, as it's a derved class of the ThisApplication...
    Thank you

    LastHope


  • KWLO

    And, however, after I've got the Application object...how should I use it in the case I described above I don't need to create a new AppointmentItem, but to convert an object into an AppointmentItem...
    Thank you

    LastHope


  • offa

    Hi,

    One option would be to pass the Application object into the Controller when you instantiate the classes. So that way your Controller can create Outlook Items using the Application Object passed to avoid the Object Model Guard.

    With this approach you do not need to change your current design and continue to have your VSTO project reference the Controller project.

    Thanks.


  • Camlan

    No, unfortunately not T_T...
    Bye

    LastHope


  • Peter Hancock

    Did you ever figure this one out I need to avoid the Object Security as well. Thanks.

  • Help with Outlook Object Model Guard...