Alternative to CommandBarControl for Outlook 2013 VSTO add-in - c#

I have a small VSTO add-in that I've used with Outlook 2010 for some time. A move to Office 2013/Outlook 2013 is soon happening and so the add-in needs to be re-written to work with Outlook 2013.
The Outlook add-in is triggered by a custom ribbon button. When triggered, the add-in will create a new meeting request window and fill the message body with some custom content. After which the user can complete the meeting request and send it if they so desire.
The issue I'm currently having is that previously, this message window was created using the CommandBarControl object to programmatically trigger a click of the "New Meeting" button in Outlook. This worked in previous versions of Outlook, but I gather that the CommandBarControl object has been removed from Outlook 2013 and now fails silently. This is indeed what I am seeing.
The original code that was being used to create the new meeting request is this:
Explorer activeExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
CommandBarControl commandBarControl = activeExplorer.CommandBars.FindControl(Type.Missing, 1106);
commandBarControl.Execute();
appointmentItem = (AppointmentItem)Globals.ThisAddIn.Application.ActiveInspector().CurrentItem;
appointmentItem.MeetingStatus = OlMeetingStatus.olMeeting;
appointmentItem.RTFBody = message; // message is a byte array being passed in from elsewhere.
The FindControl() method is used to find the "New Meeting" button in Outlook and then Execute() a click action on that button.
An alternative might be something like this:
appointmentItem = (AppointmentItem)Globals.ThisAddIn.Application.CreateItem(OlItemType.olAppointmentItem);
appointmentItem.MeetingStatus = OlMeetingStatus.olMeeting;
appointmentItem.RTFBody = message; // message is a byte array being passed in from elsewhere.
appointmentItem.Display(false);
The second code block will also create a new meeting request window and works in Outlook 2013, however there are a couple of subtle but important differences with the second code block...
The created meeting request will not inherit the date and time that a user has previously clicked on in their calendar, instead it will default to the current date/time regardless of what date/time the user has clicked on in their calendar.
The created meeting request will not respect the situation where a user is creating a meeting request "on behalf of" another user, because it ignores which calendar has been clicked on before the user initiated the new meeting request.
So my question is this: how can one now programmatically create (using a VSTO add-in) a new meeting request in Outlook 2013 that will respect which calendar the user has clicked on before hand? That is, it will satisfy the above two requirements that previously using the CommandBarControl object managed to satisfy?

You are right, Command bars were deprecated in Office 2010. Now the Fluent UI is used instead. You can read more about the new UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
You can run the required ribbon button programmatically using the CommandBars.ExecuteMso method (see the CommandBars property of the Explorer and Inspector classes). You just need to pass the idMso value of the built-in control you need to run. The following links provides lists of built-in controls for Office 2010 and 2013:
Office 2010 Help Files: Office Fluent User Interface Control Identifiers
Office 2013 Help Files: Office Fluent User Interface Control Identifiers

Related

Set the category of an email using custom Outlook Web App Addin

I have a scenario where my Outlook Web App Add-in looks for the same email by subject in a database through API. If this email found in the database, I want to mark that email with some categorization so that user can visualize which emails have already been in the Database.
I am using the Office.js to get the subject and pass it to the API as through ajax call. The API written in C# looks into the database and return true or false.
if it returns true, I want to mark this email with category red from the code automatically.
Red category means follows.
Currently, there is no way of dynamically setting categories.
We track Outlook add-in feature requests on our user-voice page. Please add a feature request there. Feature requests on user-voice are considered when we go through our planning process.

How to get actual list of Outlook accounts in Add-In after adding or removing an account by user?

My Add-In should change its mode if the list of accounts is changed.
I get the list of outlook accounts the following way:
var ns = application.GetNamespace("MAPI");
accounts = ns.Accounts;
It works, but when user adds new account or remove some of them, the ns.Accounts still shows old value. It's changed only if I reload outlook.
Also I have been searching events for adding and removing accounts and still can't find.
Could you please help me?
There are no events that occur in the Outlook Object Model when accounts are modified. You have to restart Outlook in order to see the changes. The only other related option is to monitor the Stores.StoreAdd event if the user opens or adds a Data File to the profile, but that's probably not useful for your needs.
Otherwise you can use a third-party library like Redemption, which can monitor changes to Accounts: http://www.dimastr.com/redemption/RDOAccounts.htm#events

Add .ics file to outlook without the user downloading it

I am writing an ASP.NET webapp together with some other students. We have to make it possible to schedule an appointment in outlook. So far we were able to create a .ics file with the dday iCalendar library. the user can download it and add it to outlook. is there a way to add the ics immediatly to the outlook calender withouth the user forcing to download it?
Yes, if the user is using IE and you site is added to the list of trusted sites. If these conditions are met, you can use the Outlook Object Model from your client side Java Script to create an instance of the Outlook.Application object using new ActiveXObject('Outlook.Application'). You can then call Application.CreateItem(1) (1 stands for the olAppointmentItem enum). Populate all the AppointmentItem properties and call AppointmentItem.Save.

Custom Alerts SharePoint 2010 (KB 948321)

I've been trying to create a custom alert for SharePoint 2010 using the following guidelines : http://support.microsoft.com/kb/948321/en-us
At this point I haven't succeeded in getting the alert to work. I was wondering of this guide also applies for SharePoint 2010. Because at the button of the article is clearly states:
APPLIES TO
Microsoft Office SharePoint Server 2007
Microsoft Office SharePoint Server 2007 for Search (Enterprise Edition)
Microsoft Office SharePoint Server 2007 for Search (Standard Edition)
Can anyone enlighten me?
Kind regards
Oxillery
I have it working in 2010.
A new Alert Template.
a.Original is found here:
\14\TEMPLATE\XML\alerttemplates.xml
b.The custom templates are found in this file which has the original definitions plus the custom definitions.
CCPersonalAlertTemplates.xml
c.Load them with stsadm
stsadm.exe -o updatealerttemplates -url "http://Beefy.com/Sites/my_name" -filename " \CCPersonalAlertTemplates.xml"
d.Every out of the box solution has a matching custom template.
The custom templates have a .ext at the end of their name.
The custom features also call a custom NotificationHandlerAssembly like this:
<Properties>
<NotificationHandlerAssembly>Shared.CCPersonalEmail, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5694e116d3fc8c0c</NotificationHandlerAssembly>
<NotificationHandlerClassName>Shared.CCPersonalEmail.CCPersonalClass
</NotificationHandlerClassName>
<NotificationHandlerProperties />
</Properties>
Custom Notification Handler assembly
a.IAlertNotifyHandler that implements an OnNotification method
- Attempts to send the custom alert (if it fails send normal alert.)
Custom alert:
Gets the PersonalEmail field data from the User Information List
If Personal Email is empty it just sends normal alert
If personal email is populated
Send normal email to internal email
Send reduced email to external address
Replace http:// with external address http://extranet-
Regex replace (keep content data from being sent)
<td class=\"formlabel\">.*<td class=\"altvb\"> </td>
Make all the alerts use the external template
Existing alerts:
Site.allwebs.alerts get flipped to the same template name they had with .ext appended
Future alerts:
Site.allwebs.lists flipped the attached alerttemplates to their .ext counterpart
Future webs and their Future lists
SPListEventReceiver ListAdded() event flips the template on all lists created in the site collection
Housekeeping
a.During feature activation
create a PersonalEmail field on the rootweb’s User Information List (This becomes content so it is not removed upon deactivation)
flip all lists and alerts to the custom alert templates.
During feature deactivation
Flip all lists and alerts back to their respective out of box alert templates

Handling attachment events in an outlook add-in

Is anyone aware of a technique I could use to override someone opening an email attachment within an outlook add-in?
Essentially what I'm being asked to do, is for certain attachments, to change the behavior so instead of opening the attachment the user is redirected to a webpage.
I can hook into the attachment context menu with Application.AttachmentContextMenuDisplay however that is not fired if the user simply double clicks on an email attachment.
Environment used is VS2010, c#, and outlook 2007/2010.
You should take a look at the ItemEvent BeforeAttachmentRead and BeforeAttachmentPreview. See this related post for reference.
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentRead += new Outlook.ItemEvents_10_BeforeAttachmentReadEventHandler(ItemEvents_BeforeAttachmentRead);
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentPreview += new Outlook.ItemEvents_10_BeforeAttachmentPreviewEventHandler(ItemEvents_BeforeAttachmentPreview);

Categories

Resources