Oultook 2013 InlineResponse - Disable Forward button - c#

I have a Form Server running in Outlook and I specify a different MessageClass (say IPM.Note.Test) for items which are to be handled by my form server. If you select an item, with MessageClass IPM.Note.Test, in the explorer view, and try to Forward from ribbon button, I prevent the user from doing so, by hooking into Forward command.
In OL 2013, if you have reading pane visible, and select an item in Explorer, you can see its preview and can Forward/Reply/ReplyAll from toolbar at the top of the reading-pane, which would create an InlineResponse.
I want to hook into this Forward action, and prevent the user from doing so, as I do for the Explorer-Ribbon Forward command.
I am aware of the Explorer.InlineResponse event which is fired on any action which creates an Inline Response, but this event is fired after the action, not before it, and it fires for Reply, ReplyAll and Forward, all three of them. I only want to intercept Forward. There is no information in the event to tell which action triggered it.
Is there a way to identify the the action which triggered the event, before the InlineResponse is created?
Or is there a way to stop the InlineResponse from being created? (From code, as I know you can disable it in OL options).
Or is there a way to disable these actions/inline response from Explorer.SelectionChange event?
I would appreciate any help.
Thanks.

MailItem object exposes the Actions collection. Retrieve the Forward action, set the Action.Enabled property to true, call MailItem.Save.

You need to set the Enabled property of the corresponding Action object instance to false. True if the action is enabled in the application and false - if the action is disabled.

Thanks guys for taking time to answer this.
Something else came up and I put this issue on hold for a bit.
As I mentioned earlier, I have my own Form Server with a different MessageClass. So the MailItem object I get in ExplorerSelectionChange event, is not a pure Outlook MailItem, its rather my MailItem and unfortunately, at the moment, its unable to get Actions property on it, probably because my Form Server implementation doesnt return a proper one.
So, although, for a normal MailItem, Enabled property will work, it doesnt solve my problem ... :(
I x-posted to Outlook Dev Forum as well, and someone suggested the following:
Private Sub myOlExp_InlineResponse(ByVal Item As Object)
Dim a As MailItem
Set a = Item
If a.To = "" Then
a.Close olDiscard ‘close the mail item
MsgBox "Forward is not supported"
End If
End Sub
Although a bit hacky, and not a great user-experience, but I'm taking this for an answer for the moment, as it works.
Shared here, in case someone else comes looking for it.
Complete thread

Related

VSTO, there is an event when i change open inspector?

good day
I must add a button in the ribbon bar only for few specific mailitem,
i use this attribute to change the visibility.
getVisible="EnableControl"
and i use
IRibbonUI UIrib.Invalidate();
to update the ribbon, there is an event that run when i change focused ispector, so i can check if the button must be displaied or not
or a totally different way to do do this control?
Thanks for your support.
Best regards
You could refer to the link below: Switch focus to Outlook active window .
If you can't solve your problem, please let me know and I can give you a solution.
Whenever Application.Inspectors.NewInspector event fires, call IRibbonUI.Invalidate. Outlook will invoke all button state callbacks, including the getVisible callback.

limiting tabbing to a custom in-window message box

I have made a custom MessageBox for my application and it launches as a UserControl. I have two buttons inside it and I would like to allow users to press Tab to switch between Buttons. However, since it's a UserControl overlaying the content, Pressing tab more than twice makes the focus go in the background on elements that aren't supposed to be tabbed at.
I can't figure out a good idea how to prevent this, I've thought of making a method that will select all elements and make their IsTabStop values to false and then restore them later, but I think that would be more of a problem then a solution.
Is there a way around this to limit tabbing only to the UserControl?
I would also appreciate advice on working with the message box.. the whole messagebox is an async function that has an infinitive loop until the answer is given. Is there another way to stop the application until one of the message box options was selected?
Crowcoder's reference has lead to correct MSDN page where I found my solution:
dialog = new UCMessageBox("Are you sure you want to exit the application?", MBType.YesNo);
AppMessageBox.Children.Add(dialog);
KeyboardNavigation.SetTabNavigation(dialog, KeyboardNavigationMode.Cycle);
The key was to call .SetTabNavigation function and direct it to my dialog (custom UserControl for the message box) and setting the KeyboardNavigationMode to Cycle.
After closing the UC rest of the application continued normally regarding navigation.

C# Outlook PST folder click event

I'm trying to find a way to capture a Mouse Click event on a folder inside a PST.
I've looked for events on Outlook.Folder interface but there is none that applies :(
Is there a way to accomplish this ? Thank you
Yes, there is. The Outlook object model provides the following events for the Explorer class:
BeforeFolderSwitch - is fired before the explorer goes to a new folder, either as a result of user action or through program code. Note, the event handler may cancel the action setting the boolean parameter to true.
FolderSwitch - is fired when the explorer goes to a new folder, either as a result of user action or through program code.
If you want to display a webpage for a particular folder, Then you need to set the MAPIFolder.WebViewURL and WebViewOn properties.

Outlook 2013 Form Region and the Delete Key

So, I've finally had to deal with this annoying issue. It seems that it's a known "bug" and there doesn't seem to be a great work-around. I was wondering what seems to be the best work around for this.
A little bit of info. In my form region I have a Winform control and a WPF control. The user can't do certain key combinations on the Winform control (Ctrl-A to select all, Delete key deletes email instead of highlighted text), but everything works fine on the WPF control.
I've tried adding the Winform control to the WPF control using a WindowsFormHost, but that made it worse as it wouldn't register the backspace key after that. I tried capturing the delete event for the email, but I can't get the .BeforeDelete to trigger. Same for the Explorer.BeforeItemCut event. Currently I'm trying to capture the WndProc event to re-direct the key events, but it seems like there should be a better/easier way.
Not sure how to continue from here. Any help in direction is welcomed. Below is my how I'm trying to capture email delete event.
Outlook.MailItem _selEmail;
// This does get triggered
private void Explorer_SelectionChange()
{
var actExplorer = this.Application.ActiveExplorer();
if(this.Application.ActiveExplorer().Selection.Count > 0)
{
var selObject = actExplorer.Selection[1];
if(selObject is Outlook.MailItem)
{
_selEmail = selObject as Outlook.MailItem;
_selEmail.BeforeEmailDelete -=
new Outlook.ItemEvents_10_BeforeDeleteEventHandler(Email_BeforeDelete);
_selEmail.BeforeEmailDelete +=
new Outlook.ItemEvents_10_BeforeDeleteEventHandler(Email_BeforeDelete);
}
}
}
// Haven't gotten this to trigger. The Console.Write("") is there
// only for a breakpoint;
private void Email_BeforeDelete(object sender, ref bool cancel)
{
Console.WriteLine("");
}
First of all, I'd suggest breaking the chain of property and method calls and declare each property or method call on a separate line of code. Thus, you will be able to release underlying COM objects inplace. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about that in the Systematically Releasing Objects article in MSDN.
Try to turn off the Single key reading using the space bar option in Outlook which allows you to move quickly through your messages in the Reading Pane. The space bar scrolls the current item. At the end of the item, it jumps to the next unread item in your message list.
Finally, using WPF controls on Outlook forms produce a well-known issue. Outlook has a habit of swallowing various keys and not sending them along to your code or form region. The spacebar, tab, backspace keys are among those affected when the keys are pressed in the reading pane. You can find a similar forum thread.

Silverlight 4 - downloading data into tooltip w/ Bing Maps

I'm adding a syndication (RSS) feed into a Bing maps application where the data is downloaded and populated on a mouse over event. The download is super fast but of course it has to be downloaded asynchronously meaning the user won't see the tooltip populated until the next time they mouse over that tool tip. I know that, for security reasons, I shouldn't necessarily be able to emulate a mouse-over event, but I know there are other things like this where there is a workaround (for example, if a user is logging in and enters their username and password - there's a workaround so that they can press 'ENTER' without the Login/Submit button having focus).
So first I'm wondering if there's a workaround and, if not...is there an easier way to do this than emulating a synchronous download via coroutines (worth noting: MVVM can not be used here due to the way the nature of the model - Also, each pin has its own tool tip rather than a single custom tool tip where the position would be determined on mouse over via MapLayer.SetPosition)
Thanks!
figured it out - just attach a boolean property on the mouse enter event and to make sure the mouse is still over the element providing the tool tip - on mouse enter set the mouse leave bool to false and the tool tip's IsOpen property to false. When the download has completed - bind your DataContext to the object with relevant data (or however you want to go about this) then, if mouse leave bool is still equal to false, set the IsOpen property = true

Categories

Resources