How to handle outlook new message windows notification from Outlook Add-in - outlook

I have an Outloook Add-in that implements a kind of client-server communication with a background process. I have a custom window which is filled in with some information and then it is passed in to a background process (using System.Net.HttpClient.PostAsync) which processes it.
After background process finishes processing that information, it informs to Outlook Add-in about that, then Outlook Add-in handle this, creates a new Outlook email that appears as a new message in the Outlook inbox and finally shows a windows notification in the system tray informing the user about that.
Now I would like to handle from Outlook Add-in the event that is fired when user clicks on the Windows notification popup in the system tray so that Outlook Add-in can open a new window to display all the information processed by the background process.
So is it possible to do it? If so, could you please provide me some code snippets or examples, or even some kind of guide to start in? I have google and I haven't found anything about that.

Yes, it is possible. But VSTO (nor Outlook) doesn't provide anything for that. That is a pure .net topic. Consider your VSTO add-in as a regular Windows application based on .net platform.
I suppose the NotifyIcon component is used for displaying a notification in the tray. In that case you can use the NotifyIcon.BalloonTipClicked event which is fired when the balloon tip is clicked.
The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the BalloonTipClicked event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.
To run the example code, paste it into a project that contains an instance of type NotifyIcon named NotifyIcon1. Then ensure that the event handler is associated with the BalloonTipClicked event.
MessageBox.Show("You are in the NotifyIcon.BalloonTipClicked event.");

So you are trying to create a fake email in the Inbox folder that looks like it was received? You cannot force Outlook to display new message notification - that can only be done from a transport provider by calling IMAPISupport::Notify and passing fnewNewMail flag.
You can of course create a fake message in the Inbox folder that looks like it was received (a bit convoluted in OOM but very easy using Redemption (I am its author) or Extended MAPI).
The best you can do is create your own tray notification that will open the message and display it (MailItem.Display) when the user clicks on it.

Related

How to track active screen in outlook mail using add-in

i'm running timer on task pane Add-in in outlook. when user inactive means if user switch to other tab I need to stop timer and when user back click on outlook mail, I need to resume timer. can anyone guide how to do this?
OfficeJS doesn't provide any events for that. You may consider posting your suggestion to the Tech Community at https://aka.ms/M365dev-suggestions, feature requests are considered when the team goes through our planning process. Don't forget to use the Github label: “Type: product feature request”.
In case of COM based add-ins (VSTO) you could handle the Inspector.Activate an Inspector.Deactivate events for the inspector windows in Outlook. If you need to deal with Explorer windows you may consider using the Explorer.Activate

Office Outlook add-in (web) how to know if new mail arrive

I'm trying to develop an add-in in office outlook where add-in should automatically read incoming emails and process my logic to it. I have developed the functionality when I have to specifically click the email to process my logic. But I want the functionality where the add-in should automatically process all incoming emails without manually clicking them.
Have implemented below points as of now:
outlook pinnable task pane
Item Changed Event
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, ItemChanged);
function ItemChanged(eventArgs) {
/*code*/
}
This is currently not possible. The addins are tied to the item in the view and hence the item needs to be selected for the add-in to work on. We track Outlook add-in feature requests on our user voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process.

Outlook Add-ins closing when a new email is opened

Whenever I have an add-in open in outlook, it closes immediately when I open a different email. Is there a way to keep an add-in open while I browse through multiple emails? Or is outlook coded in such a way that forces the add-in to close every time you click on a different email?
Thanks.
As far as I understand your questions you are the user of the Outlook Add-on. If this is correct, you will not be able to change this behavior. Every time you switch the item you would need to click to invoke the add-on once again. You may also contact the developers of this add-on and request them to implement a pinnable taskpane with explanation of your business case.
Well, if I was wrong and you are the developer of this add-on, you should look at pinnable taskpane in Outlook. This would cover exactly the case you have described. What you would need to do is just support VersionOverrides v1.1 schema in your add-on manifest as well as register and implement the Office.EventType.ItemChanged event handler in your add-on JS implementation.

Send add-in for Outlook UI

Is it possible for a javascript-based send add-in for Outlook to present a custom UI like you can in the VSTO add-in model? Based on all the examples I've seen, it looks like they only determine whether the message can be sent based on some analysis performed on the Outlook item. An alternative solution would be two write two add-ins, one task pane and one send. The task pane add in would have to be explicitly invoked, which would add another step that my users do not need to perform with the VSTO add-in. The send add-in would analyze the message to determine whether the task pane add-in has acted on the message. If there's a way to display a UI in the send add-in, users could still use their existing workflow to get their messages processed as they are accustomed to. Thanks in advance!
It isn't possible to surface a customer UI using On Send. If the message fails your validation process, Outlook handles surfacing your message:
Also keep in mind that each add-in runs within it's own sandbox. It isn't possible for one add-in to trigger another or to send messages between two add-ins from within Outlook. You good handle cross-add-in messaging via a shared back-end but this wouldn't help in an On Send scenario.

VSTO Outlook Add-In: How to capture reply-to-all, reply, and forward events?

I am having trouble capturing the reply-to-all, reply, and forward events in Outlook 2013 (using VSTO for 2010).
Currently, I am having no problems with Inspector class, since those open a new window.
But when I click Reply or Reply-To-All in Outlook only and it shows in the same windows as outlook (not in a pop-out window), my Inspector event handler does not fire. It only fires when there is a new window pop-outed.
Is there any way to handle this, so that I can interject some code in between?
Thank you!
You can create an Explorer wrapper, which will wrap the main Outlook window, and put code in the SelectionChange event to create MailItem wrappers with the Forward and Reply events set up to use your code. Be sure to keep your MailItem wrapper around between selection changes so you can ensure it's disposed after the selection changes again, otherwise you'll leak wrappers and MailItems.
Alternatively, put your code on the ribbon's events, which is explained here (for Office 2007, but this hasn't changed). This approach won't handle keyboard shortcuts (ctrl-f, ctrl-r and ctrl-shift-r), though.

Resources