Martin KS
Martin KS

Reputation: 531

Events firing before 'Me.Startup' sub has finished in vb.net vsto outlook addin

I've written all the code to initialize variables in

Private Sub ThisAddIn_Startup() Handles Me.Startup

But part of my code is in a sub:

Private Sub Application_NewMailEx(EntryIDCollection As String) Handles Application.NewMailEx

I've noticed that if there's email waiting for me when I start outlook, the newmailex sub will start running at the same time as (or before) the me.startup sub.

Is there an event other than me.startup that comes even earlier, and is blocking, so that I can be sure that all my variables are ready when I get my first mails?

Upvotes: 0

Views: 72

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66225

Initialize all your variables in a single sub (CheckInitialize?) that checks a global/class flag, initializes all variables, and sets the global flag to true. You can call that sub from both Startup and NewMailEx event handlers.

Upvotes: 1

Related Questions