Create button in Outlook calendar

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

Create button in Outlook calendar
I want to add a button in the Outlook right click menu 
Steen Maigaard




Posts: 6
Joined: 2016-04-08
Hi.

I would like to add a button in Outlooks calendar menu when you right click,is that possible?

We want to be able to call CRM appointment with parameters (selected time), how can I get that?

We are very happy with your tool, good work guys.

Regards Steen
Posted 27 Apr, 2016 02:44:21 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Steen,

Thank you for your kind words!

I would like to add a button in Outlooks calendar menu when you right click,is that possible?


Yes, it is possible. Please let me know which Outlook versions your add-in shall support.

We want to be able to call CRM appointment with parameters (selected time), how can I get that?


Sorry, I do not quite understand what you are trying to do. Could you please clarify?
Posted 27 Apr, 2016 04:19:30 Top
Steen Maigaard




Posts: 6
Joined: 2016-04-08
Its for Outlook 2010 and forward

Regards Steen
Posted 27 Apr, 2016 04:41:45 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Steen,

Thank you. You need to add the ADXRibbonContextMenu component to your add-in module designer, set its Ribbons property to OutlookExplorer, open the editor of the ContextMenuNames property and add the Outlook.Explorer.ContextMenuCalendarItem and the Outlook.Explorer.ContextMenuCalendarView context menu names there. Then, populate the Controls collection by using the visual editor, rebuild and test your add-in.
Posted 27 Apr, 2016 04:51:15 Top
Steen Maigaard




Posts: 6
Joined: 2016-04-08
The button created in the context menu will be creating a new appointment in CRM. For that to work i need to pass the start and stop time for the appointment. So the functionality should be like this:

1. Select time in the Calendar
2. Click the new button
3. Call an URL and pass the start and stop time to CRM

Hope this is easier to understand

Regards Steen
Posted 27 Apr, 2016 04:52:09 Top
Steen Maigaard




Posts: 6
Joined: 2016-04-08
Hi Dmitry

Button is working but the start and stop time I had to find this way

Outlook.Explorer expl = OutlookApp.ActiveExplorer();
Outlook.Folder folder = expl.CurrentFolder as Outlook.Folder;
Outlook.View view = expl.CurrentView as Outlook.View;
if (view.ViewType == Outlook.OlViewType.olCalendarView)
{
Outlook.CalendarView calView = view as Outlook.CalendarView;
DateTime dateStart = calView.SelectedStartTime;
DateTime dateEnd = calView.SelectedEndTime;
}

How is it done using the collection ?

Regards Steen
Posted 27 Apr, 2016 05:31:56 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Steen,

As far as I understand, you have already added an ADXRibbonButton to the Controls collection, right? If so, you can handle the button's OnClick event in the following way:

private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed)
{
    Outlook._Explorer activeExplorer = OutlookApp.ActiveExplorer();
    if (activeExplorer != null)
        try
        {
            object viewObj = activeExplorer.CurrentView;
            if (viewObj != null)
                try
                {
                    Outlook._CalendarView calView = viewObj as Outlook._CalendarView;
                    if (calView != null)
                    {
                        MessageBox.Show(
                            "Start: " + calView.SelectedStartTime.ToString() + Environment.NewLine +
                            "End: " + calView.SelectedEndTime.ToString());
                    }
                }
                finally { Marshal.ReleaseComObject(viewObj); }
        }
        finally { Marshal.ReleaseComObject(activeExplorer); }
}


Also, to create a new calendar item you can use the CreateItem method, for example:

private void adxRibbonButton2_OnClick(object sender, IRibbonControl control, bool pressed)
{
    Outlook._AppointmentItem apptItem = OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook._AppointmentItem;
    if (apptItem != null)
        try
        {
            apptItem.Display(false);
        }
        finally { Marshal.ReleaseComObject(apptItem); }
}
Posted 27 Apr, 2016 07:17:54 Top
Steen Maigaard




Posts: 6
Joined: 2016-04-08
Hi Dmitry

Thank You very much, all is now working perfectly.

Regards Steen
Posted 29 Apr, 2016 08:04:46 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Steen,

You are welcome!
Posted 29 Apr, 2016 10:55:48 Top