Determining the Mailbox for an Addin in C#

B

Bill Smith

Using: Outlook 2003 on Windows XP, Exchange 2000 environment

I have an addin written in C#. It is used by an admin assistant who manages
3 different calendars. When she creates an appointment in one of the
calendars, I need to know whose calendar she is entering the appointment
for.

I cuurently hook into the 'Write' event handler (fired when anyone does a
Save And Close or Send Update operation.

I tried walking backwards up from the appointment to the 'Mailbox - xxx'
folder, but I always get the currently logged in user.

Any help?
 
K

Ken Slovak - [MVP - Outlook]

Inbox.Parent.Name should give you the name of the mailbox. You can parse out
the name by looking for "- [Mailbox - mailbox name]" and getting rid of the
text around the name.
 
B

Bill Smith

Thansk for the Reply.

But I am having difficulty finding the Inbox Item. I am in the event
handler for the Appointment Inspector. If I walk up from the appointment
object until I find "Mailbox - xxx" (which is what I was doing), I end up at
my own Mailbox (and not the Mailbox of the person whose calendar I am
editing)

Here is the code (perhaps it will help)

ai = (AppointmentItem)inspector.CurrentItem;
MAPIFolder fld = (MAPIFolder)ai.Parent;
//
// Climb up till we find out whose mailbox this is.
//
while (fld != null && fld.Name.IndexOf("Mailbox - ") == -1)
{
fld = (MAPIFolder)fld.Parent;
}
if (fld != null)
{
// strip off "Mailbox - "
owner_displayName = fld.Name.Substring(10).Trim();
}

No matter whose calendar I am adding this appointment to, the mailbox
returned is always my own




Ken Slovak - said:
Inbox.Parent.Name should give you the name of the mailbox. You can parse out
the name by looking for "- [Mailbox - mailbox name]" and getting rid of the
text around the name.




Bill Smith said:
Using: Outlook 2003 on Windows XP, Exchange 2000 environment

I have an addin written in C#. It is used by an admin assistant who manages
3 different calendars. When she creates an appointment in one of the
calendars, I need to know whose calendar she is entering the appointment
for.

I cuurently hook into the 'Write' event handler (fired when anyone does a
Save And Close or Send Update operation.

I tried walking backwards up from the appointment to the 'Mailbox - xxx'
folder, but I always get the currently logged in user.

Any help?
 
K

Ken Slovak - [MVP - Outlook]

How is the mailbox being opened? If it's not as part of your profile and is
from File, Open Other User's folder then you won't get much information. If
it's part of the profile you can easily get to the mailbox top of store
folder.
 
B

Bill Smith

It is part of my profile. It is added thru the Tools->Options->Change
Existing Accounts.....menus...

So the admin right-clicks on the other user's calendar and says "New
Appointment". The NewInspector fires. How would I go about finding the
mailbox that the calendar belongs to ?
 
K

Ken Slovak - [MVP - Outlook]

Has the item been saved at that point?

You could use the GetSharedDefaultFolder() method of the NameSpace object if
the Calendar is the default one for that mailbox. You need to supply the
folder type and a recipient corresponding to the mailbox owner.

If the item has been saved already then Item.Parent.Parent should get you to
the Outlook Today folder (top of store) for that mailbox. If the item hasn't
been saved then your own mailbox will be the parent of the item.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top