Albert Raiani

The current outlook user opens another user's calendar and creates an appointment on his / her behalf. How can I retrieve the user who is the owner of the AppointmentItem

When I handle the NewInspector event I can examine the inspector's CurrentItem and get a reference to the AppointmentItem. I can also examine the Session property but this only give me the user name of the CurrentUser.

Thank You,

Al



Re: Visual Studio Tools for Office Open folder of another user

Ji Zhou – MSFT

Hi Albert,

Are you looking for something like AppointmentItem.Organizer This one will return the owner of appointment item.

As to the session.UserName, session stands for the current connection. So the UserName will always return the current User’s Name.

Thanks

Ji






Re: Visual Studio Tools for Office Open folder of another user

Albert Raiani

Thank You! Yes, I am looking for the meeting organizer but when I query the AppointmentItem.Organizer it returns null. Only after I save an appointment does the Organizer property get populated. Even then it returns a string representing the full name of the organizer. I need a way to get the username of the organizer.

Al





Re: Visual Studio Tools for Office Open folder of another user

Ji Zhou – MSFT

Hi Albert,

Yes, this is a by-design behavior, that the Organizer/Sender only gets initial value after we save it. We can programmatically save it before retrieving its value. All the name properties returned by the item are the Display Name. If you want to get the user’s first name and last name, as far as I know, we can only use Property Accessor to get the AddressEntryID first. The following code works in my side:

Code Snippet

//Get the appointment Item

Outlook.Inspector inspector = app.ActiveInspector();

Outlook.AppointmentItem appointment = inspector.CurrentItem as Outlook.AppointmentItem;

//Save it first before retrieving the Owner

appointment.Save();

//Use PropertyAccessor to get the PR_SENDER_ENTRYID

//(0C190102 is the Hexadecimal value of PR_SENDER_ENTRYID property tag)

//For more tags' values, please refer this link:

//http://msdn2.microsoft.com/en-us/library/ms526356.aspx

object EntryID = appointment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C190102");

//EntryID is an object, we should translate it to string format for use.

//The following is my algorithm,

//You can write your more effective one

System.Byte[] s = EntryID as System.Byte[];

String id = String.Empty;

for (int i = 0; i < 76; i++)

{

if (s[i]>=16)

{

id += s[i].ToString("X");

}

else

{

id += "0";

id += s[i].ToString("X");

}

}

//Get the AddressEntry from ID, then get the ExchangeUser.

//With the user, we can get its first name and last name

Outlook.ExchangeUser user = app.Session.GetAddressEntryFromID(id).GetExchangeUser();

MessageBox.Show(user.FirstName + " " + user.LastName);

Wish this helps! And if you still have any questions about the codes, please feel free to let me know!

Thanks

Ji






Re: Visual Studio Tools for Office Open folder of another user

Albert Raiani

Thanks! This is great! Unfortunately, and I should have mentioned this earlier, I'm programming this for Outlook 2003. As I'm sure you know, PropertyAccessor is a new property in 2007. Is there an equivelent technique that I can use for 2003





Re: Visual Studio Tools for Office Open folder of another user

Ji Zhou – MSFT

Hi Albert,

ExchangeUser is only existed in Outlook 2007. In Outlook Object Model, only it can tell the FirstName and LastName. If you are using Outlook 2003, from my opinion, getting short names directly may be not achieved.

But the Display Name is composed of FirstName, LastName and some other information. Is it possible, in your scenario, to write some algorithm which can translate the Display Name to what you want

Thanks

Ji






Re: Visual Studio Tools for Office Open folder of another user

Albert Raiani

Sure it's possible to look up a user using the name but inevitably there will be times when more than one person has the same name.

Isn't it possible, using the EntryId, to do CDO and find out the Active Directory user of the appointment's organizer I can get the EntryId easy enough once the AppointmentItem has been saved.

Al