Built-in Outlook View Control

I am trying to create an Outlook 2003 add-in using Visual Studio 2008 on Windows XP SP3 and Internet Explorer 7.

My add-in uses the custom home page of the folder, which displays my custom form, which includes control over the look of Outlook.

I get a COM Exception with a description of "Exception from HRESULT: 0xXXXXXXXX" every time I try to set the Folder property for OVC. The error code is a random number, each time a different one. This is not the first access to control properties; before that, the View and ViewXML properties are already set. The control is marked as safe for scripting.

I am using the value of the CurrentFolder.FolderPath property of the active explorer, which seems to be correct:

Outlook.Explorer currentExplorer = app.ActiveExplorer(); if (currentExplorer != null) { ovcWrapper.Folder = currentExplorer.CurrentFolder.FolderPath; } 

This is the top of the stack trace:

 System.Runtime.InteropServices.COMException (0xXXXXXXXX): Exception from HRESULT: 0xXXXXXXXX at Microsoft.Office.Interop.OutlookViewCtl.ViewCtlClass.set_Folder(String pVal) at AxMicrosoft.Office.Interop.OutlookViewCtl.AxViewCtl.set_Folder(String value).. 

This only happens if the folder is in a different .pst file. Going to the folder inside the PST file by default will not throw an exception.

I must emphasize that everything went perfectly before I went on vacation :). Windows XP seems to have installed some updates that by default changed the protection of Internet Explorer or Outlook 2003 while I was away.

On the other hand (virtual machine), everything works fine with Office 2007 and Internet Explorer 6 without any updates.

+4
source share
2 answers

After a while, I finally find out what the solution is: change the name of the external storage to something new.

When launched, addin downloads a PST file that is different from the standard and changes its name (not the name of the pst file, but the name of the root folder) to "Documents".

This is the code:

 session.AddStore("C:\\test.pst"); // loads existing or creates a new one, if there is none. storage = session.Folders.GetLast(); // grabs root folder of the new fileStorage. if (storage.Name != storageName) // if fileStorage is brand new, it has default name. { storage.Name = "Documents"; session.RemoveStore(storage); // to apply new fileStorage name, it have to be removed and added again. session.AddStore(storagePath); } 

The solution should not use “Documents” as a name, but something new. The problem is not related to a specific name.

+2
source

Dobry Dan, nency :)

I don’t know if I can really offer a “silver bullet” solution based on the information here ... but here are some ideas / notes that you can try:

When working with Outlook on several projects in the past, I can say that sometimes it’s a funny bird when it comes to providing / providing access to external users / processes. Sometimes a user needs to manually confirm access or log in ... so make sure you have

 app.Session.Logon() 

took care of something.

Another thing I notice is the use of app.ActiveExplorer() Make sure this function returns exactly what you think; It occupies the topmost window on the user's desktop ... which is usually the usual, but not always, window you are trying to work with, so just double-check it.

+1
source

Source: https://habr.com/ru/post/1277162/


All Articles