2

I am programming Outlook 2003 add-in using Visual Studio 2008.

Add-in uses embedded user control in folder's home page, like as it was recommended. Here is HTML code for folder's home page:

<html><head><style type="text/css">body{overflow: hidden}</style></head>
    <body rightmargin = '0' leftmargin ='0' topmargin ='0' bottommargin = '0' onload='OnBodyLoad()'>
        <script>
            function OnBodyLoad()
            {
                var outlook = window.external.OutlookApplication;
                FolderView.Initialize(outlook);
            }
        </script>
        <object classid='clsid:C718A848-6C31-4897-8DA8-0EDE3A4C6F14'
            id='FolderView' VIEWASTEXT width='100%' height='100%' />
    </body>
</html>

HTML code is inserted in HTMLDocument property of the active explorer during FolderSwitch event.

In control's OnLoad event, a reference to application instance is used (which was passed as a parameter to its Initialize method), but sometimes control is not initialized before OnLoad event is fired. It is just created, but Initialize method is never invoked.

Does somebody has similar experiences? Is this usual behavior?

Xaruth
  • 4,034
  • 3
  • 19
  • 26
Nenad Dobrilovic
  • 1,505
  • 1
  • 15
  • 29
  • Is this still a useful question. Also, perhaps a bounty is in order if it is? – Ben Dauphinee Sep 05 '10 at 13:46
  • I believe it is still useful, but I'm not working on this project anymore so I couldn't check an answer. And it's a subtle one which makes a definitive choice of right answer even harder. – Nenad Dobrilovic Sep 07 '10 at 08:29

1 Answers1

1

I have no experience with Outlook 2003 or any other version of it, BUT I know about html and JavaScript, so I would recommend to not fire the method instantly cause in some "browsers/clients" the values used inside or the things need it to continue inside the method are not available yet. You better add a delay when calling the method and maybe that will fix your problem, cause that have solved many of my problems in the past.

Example:

document.addEventListener('onload', function (e) { yourFunction(params); }, false);

NOTE: it might be onload or onbodyload.

Denis Pshenov
  • 11,157
  • 6
  • 42
  • 42
Jorge Aguilar
  • 3,442
  • 30
  • 34