Accessing inspector object from inspector command bar control's event handler

Add-in Express™ Support Service
That's what is more important than anything else

Accessing inspector object from inspector command bar control's event handler
 
gera




Posts: 95
Joined: 2009-04-28
Hi,

I have added a ADXCommandBarComboBox control to the inspector of the appointment items. Now in the change event of the command bar control, I need to access the inspector item and its corresponding item. As the event handling is in the Add in module, am not sure how exactly I can get the particular inspector object. Please let me know.

Thanks in advance.
Gera.
Posted 26 Oct, 2010 07:17:50 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gera,

You can use the following code (C#):

private void adxCommandBarComboBox1_Change(object sender)
{
    Outlook.Inspector inspector = OutlookApp.ActiveInspector();
    Outlook.AppointmentItem appointmentItem = inspector.CurrentItem as Outlook.AppointmentItem;
    // your code goes here
    if (appointmentItem != null) Marshal.ReleaseComObject(appointmentItem);
    if (inspector != null) Marshal.ReleaseComObject(inspector);
}


Does it work for you?
.NET, Extended MAPI, Windows Phone & RT
Posted 26 Oct, 2010 07:26:26 Top
gera




Posts: 95
Joined: 2009-04-28
Yeah, This works. Thanks for your reply.

Now I have an other problem. I have code like this.

this.adxOutlookEvents.NewInspector += new AddinExpress.MSO.ADXOlInspector_EventHandler(this.adxOutlookEvents_NewInspector);

void adxOutlookEvents_NewInspector(object sender, object inspector, string folderName)
{
Outlook._Inspector olInsp = inspector as Outlook._Inspector;
if (olInsp.CurrentItem is Outlook.AppointmentItem)
{
Outlook.AppointmentItem item = olInsp.CurrentItem as Outlook.AppointmentItem;
Outlook.UserProperty prop = item.UserProperties.Find(Global.Settings.BookingType, true);
if (prop == null)
prop = item.UserProperties.Add(Global.Settings.BookingType, Outlook.OlUserPropertyType.olText, true, Type.Missing);
prop.Value = appInspBookingTypeComboBox.Text;
}}}

I get the prop value to be null, so when it tries to add the UserProperty, I get the following error "A custom field with this name but a different data type already exists. Enter a different name."

I am not able to check the particular UserProperty that already exists. The UserProperties.Count is 0 before dding the property and it is 1 after adding the property. So I have no idea why it gives the error. Please help.

Thanks in advance.
Gera
Posted 27 Oct, 2010 03:27:25 Top
gera




Posts: 95
Joined: 2009-04-28
Also, I have a situation where I need to handle the Save and Close of a normal appointment creation and add some extended properties to it and create the appointment through Exchange web services. The appointment can be created in my calendar or another user's calendar for which I have write access.

Now when handling the event, in the AppointmentItem, how do I know the user for whom the appointment is created. I am not able to find out the correct variable which contains the user information.

Thanks,
Gera
Posted 27 Oct, 2010 04:26:20 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gera,

1. Please try to save the appointment item. Does this help?
2. The Namespace class provides you with the CurrentUser property. Is it what are you looking for?

FYI To get assistance with host applications’ objects, their properties, and methods as well as help info, use the Object Browser. Go to the VBA environment (in the host application, choose menu Tools | Macro | Visual Basic Editor or just press {Alt+F11}), press {F2}, select the host application in the topmost combo and/or specify a search string in the search combo. Select a class /property /method and press {F1} to get the help topic that relates to the object.
.NET, Extended MAPI, Windows Phone & RT
Posted 27 Oct, 2010 04:40:49 Top
gera




Posts: 95
Joined: 2009-04-28
Hi,

1. No it doesnt help. But anyway I am having a different name now. So the problem is not there now.

2. NO, I am not looking for that. Say I open another person's shared calendar in my outlook and I try to create a new appointment in that person's calendar. So my question is, in the AppointmentItem object, where that person's identity is specified (meaning username or email which specifies that the appointment is created for that person).
So then I can take that information and create the appointment for that person through the exchange webservices.
Posted 27 Oct, 2010 05:09:23 Top
gera




Posts: 95
Joined: 2009-04-28
Hi

One more issue here.

3. I have added a ADXCommandBarComboBox control to the inspector of the appointment items. I guess its just a single control which gets shown in all the inspector windows. The result is that when I change the value of the combobox in one inspector, it gets changed in all the inspectors. What I want to do is to select different values in the comboboxes of different inspectors. I can use the ADXCommandBarComboBox for this, right?
Posted 27 Oct, 2010 05:25:54 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gera,

1. Is the issue resolved now?
2. Did you try to use the current folder name? Please have a look at the article in MSDN.
3. Please make sure that you use the AddinExpress.MSO.ADXOlInspectorCommandBar component (not AddinExpress.MSO.ADXCommandBar).
.NET, Extended MAPI, Windows Phone & RT
Posted 27 Oct, 2010 11:13:55 Top
gera




Posts: 95
Joined: 2009-04-28
Hi,

1. The problem is not yet resolved, but I have a workaround as I dont have much time to solve the particular issue. So you can have it as resolved.

2. The article uses the person's name to display the shared calendar. But what I want is the name or email id of the person for whom the appointment is being created either it is self calendar of another person's calendar.

3. OKay, I will try that. Thanks.
Posted 28 Oct, 2010 02:36:57 Top
gera




Posts: 95
Joined: 2009-04-28
3. Actually I have AddinExpress.MSO.ADXOlInspectorCommandBar component and not AddinExpress.MSO.ADXCommandBar.

I have AddinExpress.MSO.ADXOlInspectorCommandBar which has ADXCommandBarComboBox.
Posted 28 Oct, 2010 02:40:10 Top