Opening WinForm in Outlook 2003 VSTO Addin with Wordmail enabled

Status
Not open for further replies.
E

enJpZGVyMzUw

I have been banging my head with this issues for sometime now. Can someone

PLEASE help??? When I create a commandbar on a new inspector window that uses

word mail, the form that opens doesn't fully load. I have done a lot of

research on this and I believe it is a threading issue because I create my

command bar in word which is subclassed into Outlook. When wordmail isn't

enabled the apartment state of the executing thread is STA and when wordmail

is enabled it is MTA. I have tried to use a delegate to instantiate the form

instead with no success. Below are a couple of relevant posts I have found.

mentions in one of these that he used several API calls to make

this work. Can someone please provide a working sample. If you need a sample

to reproduce I can provide one. I used the code sample to load wordmail

toolbars on the inspector_activate event. I added another windows project and

then tried to instantiate the form from my class. It never fully loads. Below

are some links I have found helpful.

http://social.msdn.microsoft.com/forums/en-US/vsto/thread/648a2c92-5690-4dc0-bfc0-57545abd721b/
 
K

Ken Slovak - [MVP - Outlook]

Andrew's post is more relevant to what you're talking about in cases of

managed code, what I was posting about relates mostly to working with VB6

code.

For managed code you have to do thread context synchronization callbacks.

What you do is on NewExplorer() and NewInspector() event handlers you call

Windows.Forms.Application.DoEvents() to prime the message pump and then you

get the current thread context, which in that case is the context of the

main Outlook addin thread. You store that context so it's always available.

Then when you want to open a form you set up a callback to a procedure that

will run in the main thread context and pass your form name along to that

callback.

// In a class context where it will stay alive:

private static System.Threading.SynchronizationContext _syncContext = null;

In the main thread event handlers code something like this:

if (_syncContext == null)

{

System.Windows.Forms.Application.DoEvents();

if (System.Threading.SynchronizationContext.Current != null)

{

_syncContext = System.Threading.SynchronizationContext.Current;

}

}

Then when you want to show the form:

// whatever arguments you want to pass to the callback are added here

object[] args = { };

System.Threading.SendOrPostCallback callback =

new

System.Threading.SendOrPostCallback(callbackClass.callbackProcedure);

if (callback != null)

{

System.Threading.SynchronizationContext context = Globals.SyncContext;

if (context != null)

{

context.Send(callback, args);

}

In this case Globals.SyncContext accesses the stored context.

callbackClass is where the callback function lives and it's named

callbackProcedure. That procedure is what displays the form and populates

any controls from the arguments passed to it. In that callback the argumens

are passed as (Object state) and are decoded there as follows:

object[] arguments = (object[])state;

Then that array has all the arguments passed to the callback.

Note that this is not necessary for Outlook 2007, only for WordMail in

earlier versions of Outlook.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
U Disable "Always ask before opening" Dialog Using Outlook 3
Wayne Outlook locks up when opening "Manage Rules & Alerts" Using Outlook 7
B Outlook 2010 Opening Mail Attachment Using Outlook 2
A Warning When Opening attachment Using Outlook 7
D Prevent popup of "Do you want to save changes?" when closing after opening an appointment to view Outlook VBA and Custom Forms 2
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
J Outlook 2010 Changing events in Outlook calendar via opening file, importing CSV Using Outlook 0
L What are the risks of opening an Outlook 2016 .pst file in Outlook 2010? Using Outlook 4
D Outlook 2007 crashes when opening an email Using Outlook 2
A Outlook 2016- unable to have all subfolders expanded when opening outlook Using Outlook 11
GregS Immediate crash on opening Using Outlook 3
Diane Poremsky Error Opening Outlook and Control Panel's Mail Applet New Slipstick.com Articles 0
S my vbscript button1_click code works on appointment created but not on opening an existing apntmn Outlook VBA and Custom Forms 16
N Wishlist Opening Outlook where we left off Outlook Wishlist 0
J Opening Attachments - in People Using Outlook 2
Mistyfied Outlook 2016 not opening Using Outlook 2
M Update field codes when opening Outlook Template Outlook VBA and Custom Forms 2
R Outlook PST not opening Using Outlook 1
U .pst file error at opening outlook Using Outlook 1
A Problems Opening Excel from Outlook Outlook VBA and Custom Forms 3
Diane Poremsky Disable the Unsafe Hyperlink Warning when Opening Attachments New Slipstick.com Articles 0
S macro for opening attachments and printing Using Outlook 1
Z how to make OL (2007) to use custom contact form when importing / opening .VCF? Using Outlook 1
T Opening email causes "Contacting ..." message Using Outlook 1
K Outlook 2013 stuck "processing" when opening. Using Outlook 3
S Opening Outlook Windows Using Outlook 1
S PoP up reminder while opening the outlook? Outlook VBA and Custom Forms 1
J Opening/Archiving/Import/Export PST files Using Outlook 4
Y (Shared Folder) Using the preview pane to open and close a fax, without opening the email itself Using Outlook 1
E OL2007 on Exchange: opening OL on different computers Using Outlook 1
Z outlook 2007 - opening a contact from the search results doesn't use the custom form Using Outlook 10
T Error opening mail with pictures - "The linked image cannot be displayed" Using Outlook 3
P I'm getting an error when opening Outlook "Mobile me stopped working Using Outlook 1
D opening Word Document in a business contact? BCM (Business Contact Manager) 3
B Contact changes from Personal to Shared when opening custom form Using Outlook 0
C How to stop iCloud calendars opening by default Using Outlook 8
U outlook 2010 freezes/crashes when opening encrypted e-mails Using Outlook 0
G OLMAPI32.dII error prevents Outlook 2010 from opening Using Outlook 2
D Custom Tool Bar and/or Commands do not remain when re-opening Outlook 2007 Using Outlook 3
G opening Outlook again after closing closing? Using Outlook 0
B Outlook 2010: how to mark messages without opening? Eg for deletion Using Outlook 2
M I cannot start Microsoft Outlook 2013 directly opening a .eml message Using Outlook 1
M Opening Word Doc's in Adobe Acrobat Pro Using Outlook 9
L Opening up Contact from an Email - Outlook 2007 Using Outlook 15
0 Outlook 2010 causes computer to lose connection when opening and Send/Receive Using Outlook.com accounts in Outlook 14
G Opening messages takes too long Using Outlook 5
G Opening pst files in different versions of outlook Using Outlook 2
F Default Program for Opening .pst Files ? Using Outlook 6
mrje1 Opening a task the Insert Tab Option is not showing up and organizing Tasks Using Outlook 9
B Two server DAG setup, second server EMC not opening Exchange Server Administration 3

Similar threads

Top