Monday, January 21, 2008

Outlook 2007: How to determine if you are the owner of an Appointment

There doesn't appear to be an easy way to find out if the current user is the owner of an Appointment. Maybe I've something extremely simple, but I just couldn't find that property called IsOwner.

I basically want to prevent functionality from being available if the user has opened an Appointment that isn't in one of their own calendars (ie: readonly and from someone elses calendar). After looking through the AppointmentItem and MAPIFolder properties, I finally found something that was useful: MAPIFolder.Store. This property returns a Store object except when the Folder is a shared folder (ie: someone elses). Cool.

So, I've now created my IsOwner method:

    public static bool IsOwner(AppointmentItem anAppointment)
{
bool result = false;

if (anAppointment.Parent is MAPIFolder)
{
//
// A Store of null indicates a shared folder (ie: not the current user's).
//
result = (((MAPIFolder)anAppointment.Parent).Store != null);
}

return result;
}

This, of course, makes the assumption that if the AppointmentItem is not in a shared folder, it is in a folder that is owner by the current user. I'll need to confirm this, but for now it allows me to move forward.

8 comments:

Unknown said...

Hallo,

how do I get GlobalAppointmentID in Outlook 2003 using C#? I appreciate if you post me a sample code.

thanks

Adrian Brown said...

Sorry David, I don't know how to get it in 2003.

In 2007, there are a number of ways. In a FormRegion, you can cast the OutlookItem property to the AppointmentItem class and access it from that.

If you have access to the Inspector, you can cast the CurrentItem property to AppointmentItem and access it that way.

Hope this helps.

Cheers,
Adrian.

AbCode said...

Hi Adrian,
Hi,
I am facing a very strange problem,hope you could help me.
I have added NewInspector event in order to get to know that which mails user has opened.It works perfect but when once i minimize the Outlook 2007,it stop working and it never fires any event or may b my event handler stop working,i am not sure wats going now but its all related to Minimizing Outlook.Please help me out

best regrds

Adrian Brown said...

Zainu, sounds like you have a reference count issue. Make sure you are keeping a reference to the objects you are listening to events on.

Cheers,
Adrian.

AbCode said...

Hi Adrian,
Thanks for the reply.I don't know how stupid this question is but in my case,should store refernce of Inspectors or wat.Like in my case im using below statement in order to capture the event when user will open a new mail in a seprate dialogue.It works fine for some time but then it gets lost.
appInstance.Inspectors.NewInspector+=new InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);

Best regards,

AbCode said...

Thank you so muchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh man............its working.Keep this good work up..God bless you.
Best regards,

Suresh said...

Hi Adrian,

I have to create an add in like
Suppose i am the owner of an appointment and send the appointment/meeting request to three people.In that three people one user id compulsory to attend(i.,e our customer).Once he accepts or Declines the appointment a mail will come to me only..whereas the other two users in the appointment would not know about the status.Is there any way we can automate through any add in that other tow users also came to know that our customer has accepted/declined the meeting.

Thanks & Regards,
Suresh K

Paras Arora said...

Thanks for the post. It was very interesting and meaningful. I really appreciate it! Keep updating stuff like this.
Data Science
Selenium
ETL Testing
AWS
Python Online Classes