How to get current email in Inbox on startup

Add-in Express™ Support Service
That's what is more important than anything else

How to get current email in Inbox on startup
 
Mike VE




Posts: 168
Joined: 2007-09-09
I am developing an app that uses an Outlook Advanced Form Region to display information relevant to the current email in the Inbox. It works fine when I select a different message in the Inbox. I use the form's ADXOlFormInboxAssistant_ADXSelectionChange() event to get the current object and cast it to a MailItem.

The problem is when Outlook starts up. I want the form region to display info about the first email selected. Although ADXOlFormInboxAssistant_ADXSelectionChange() fires at least twice during the startup sequence attempts to get the current object fail because the ActiveExplorer().Selection.Count is 0, even the last time the event fires.

Should I be using a different event?
Posted 19 Aug, 2016 07:13:03 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Mike,

Will the selection return a correct item if you click the *selected* item right after startup?


Andrei Smolin
Add-in Express Team Leader
Posted 19 Aug, 2016 08:46:23 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Yes, that works fine.

I think the problem is to do with the timing of when the OutlookApp object is available. I cannot find a FormRegion event that fires AFTER the OutlookApp object has been made available in the main AddinModule code.
That means that calls to ActiveExplorer.Selection fail.

Is there a way I can get the ActiveExplorer before AddinStartupComplete?

Or is there some other way to do it?
Posted 19 Aug, 2016 09:37:13 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Cracked it. I found that the ADXOlForm had its own OutlookApplication property and once I had got that everything else followed.

Thanks.
Posted 19 Aug, 2016 10:07:01 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Thank you for posting this!


Andrei Smolin
Add-in Express Team Leader
Posted 19 Aug, 2016 10:24:47 Top