ProbeStream
ProbeStream

Reputation: 1

VSTO-Add-In Outlook: Toastnotification overwritten

I've created an VSTO-Add-In for Outlook, which imports several data from an pdf-file and saves the data as an MS-Excel-File. After successfully process i start a Toastnotification ,which enables an fast opening of this Excel-file by clicking on the notification in the info-center. The problem: clicking on the notification of other incoming e-mails (Outlook) doesn't work anymore. Nothing happens. How can i solve this problem?

    public Ribbon1()
    {
        Initialize();
    }
    
    private async Task Initialize()
    {
        await Task.Run(() =>
        {
            ToastNotificationManagerCompat.OnActivated += async toastArgs =>
            {
                ToastArguments args = ToastArguments.Parse(toastArgs.Argument);
    
                    await Task.Run(() =>
                    {                       
                        if (!string.IsNullOrEmpty(toastArgs.Argument) && !toastArgs.Argument.Contains("idEPST=ignore") && toastArgs.Argument.Contains("idEPST="))
                        {
                            string datei = toastArgs.Argument.ToLower().Replace("idEPST=", String.Empty).Trim().Replace(".xls", "");
                            ProcessStartInfo si = new ProcessStartInfo();
                            si.FileName = "excel.exe";
                            si.Arguments = $"\"C:\\folder\\file.xls\" /{datei}";
    
                            Process.Start(si);
                        }
                    });
                };
            });
        }
    }

//and later

new ToastContentBuilder()
    .AddAudio(null, silent: true)
    .AddArgument("idEPST", filename)
    .AddHeader("identifier", "My Excel App Name", String.Empty)
    .AddText($"{name}, {firstname}", hintMaxLines: 1)
    .AddText("... sucessfully saved.")    
    .Show();

After deinstalling the VSTO-Add-In: On clicking on a e-mail-notification results in an error message: "Cannot Start Microsoft Outlook. The Command Line Argument Is Not Valid..."

Upvotes: 0

Views: 234

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

It seems there are some problems with windows registry keys, especially with .msg file associations. Because when you click on a toast notification in Outlook a corresponding item is displayed/opened.

Re-associate the .msg file by following the steps and verify the results.

  1. Click on Start and then Default Programs.
  2. Click on Associate a file type protocol with a program option.
  3. Select .msg from the Name list and then click on Change Program.
  4. Now click to select Microsoft Office Outlook and then click on OK.
  5. Restart the computer and then try opening emails saved on the Computer.

See Error: The command line argument is not valid. Verify the switch you are using. for more information.

Upvotes: 0

Related Questions