views:

1084

answers:

2

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

My add-in is using custom Folder Home Page which displays my custom form, which wraps Outlook View Control.

I get COM Exception with 'Exception from HRESULT: 0xXXXXXXXX' description every time when I try to set Folder property of the OVC. Error code is a random number, every time is different. It is not the first access to control's properties, before that, View and ViewXML properties are set already. Control is marked as Safe for Scripting.

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

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

This is 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 is happening only if the folder is located in non-default PST file. Changing to folder inside default PST file will produce no exception.

I must underline that everything worked just fine before I went to holiday :). It seems that Windows XP installed some updates which changed default security of Internet Explorer or Outlook 2003 while I was absent.

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

A: 

Dobri Dan, nency :)

I don't know if I can really offer a "silver bullet" solution given the information here...but here are a few ideas/notes to try out:

Having worked with Outlook on a few projects in the past, I can tell you that it is a funny bird sometimes when it comes to giving/granting access to outside users/processes. It sometimes requires the user to manually confirm access or log in...so make certain that you have

app.Session.Logon()

taken care of somewhere.

The other thing I notice is the use of app.ActiveExplorer() Make certain that this function is returning exactly what you think it is; It takes the topmost window on the user's desktop...which is usualyy but not always the window you are trying to work with, so just doublecheck.

BKimmel
Dobar dan :)Session is already logged in, and trying to log on again gives no results.It seems that an active explorer is always the right one, except that returned reference is null sometimes (?).Perhaps the problem lays in some security setting, which has suddenly changed?
Nenad
+1  A: 

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

During startup of the addin, it loads the non-default PST file, and changes its name (not the name of the pst file, but the name of the root folder) to "Documents".

This is 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);
 }

Solution is not to use 'Documents' as a name any more, but something new. Problem is not related to specific name.

Nenad