0

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.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Willy
  • 9,848
  • 22
  • 141
  • 284

2 Answers2

0

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.");
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
0

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.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78