More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

Add-in threading issue causes Outlook to crash or hang

If you have written an Outlook add-in with Visual Basic 6.0 and you are getting new and unexpected reports of it crashing, you might want to ask the user whether the Apple ITunes add-in is also installed. According to Outlook MVP Ken Slovak, the ITunes add-in, which synchronizes the Outlook calendar with an IPod, can cause Outlook 2007 to crash and Outlook 2003 to hang in a way that makes it look like another VB6 add-in is responsible, because of a threading issue.

UPDATE: As of 18 Jan 2008, Apple has released a new version of the iTunes add-in that does not produce this behavior.

The Microsoft support engineer whom Ken has been working with explained that Outlook was designed with the assumption that all calls to the Outlook object model are on thread 0. Some other often used DLLs also make that assumption, including the VB6 runtime (MSVBVM60.DLL), which is used in many of the Outlook add-ins currently available.
The problem apparently occurs because the Apple add-in sets up a new thread using a named pipe to do the calendar synching but neglects to marshal the thread back to thread 0 for any calls to the Outlook object model. Instead, it calls into the object model instead on thread 7. This lack of a proxying back to thread 0 then sets Outlook to call into MSVBVM60 to pass along any events that have fired due to the object model access (for example the ItemLoad event available only in Outlook 2007, which fires on every object model access to any Outlook item). This then crashes Outlook due to the threading. The stack is read by Watson and whatever is at the bottom of the stack gets blamed for the crash, usually MSVBVM60 but also Kernel32 on Vista. The next time Outlooks starts up, whichever addin was listed lowest in the stack is then blamed for the crash.
If no VB6 addin is running, Outlook doesn't immediately crash. Instead, it becomes unstable and might crash at any later time, or it might just get hung in a deadlock between threads, something that won't happen if all calls to the object model are called in thread 0.
According to Ken, there is no possible defensive programming that an add-in developer can do to prevent another add-in from causing this problem. The problem add-in must change its code to prevent the problem from occurring. Microsoft is in touch with Apple about the problem with the ITunes add-in. However, any other vendor whose add-in takes the same approach to threading will cause the same problem, which means that this is a vendor-by-vendor problem that will have to be addressed each time a problem add-in is discovered.

Newest Resources

Creating an add-in for Outlook 2013 - 2003 with a single code base -- The video demonstrates how to support all versions of Outlook 2013 – 2000 in one project using Visual Studio 2012.

Advanced Outlook Form and View Regions -- An extension of Visual Studio Tools for Office (VSTO) 2008, 2010 and 2012 that allows customizing Outlook forms and views with any .NET controls.

Auto BCC Outlook add-in -- Automatically creates bcc/cc copies of your outgoing emails based on flexible rules.

Print all attachments at once using VBA -- Udi Shitrit shows how to use the Win32 to print all of a message's attachments -- no need to know the file types involved.

Outlook 2010 MAPI Reference -- Official Microsoft reference for MAPI development against Outlook 2010. Header files are also available.

(Less than) Portable Search Folders -- Stephen Griffin explains why search folders created by Outlook object model code may not always work and offers a partial solution.

How to programmatically select a custom Form Region -- Helmut Obertanner demonstrates, with screen shots, how to create a form region for an Outlook 2007 contact form and add a button to the Ribbon to switch the Inspector display to the region.

Customize the built-in Outlook Select Names dialog (or any other) -- Helmut Obertanner demonstrates how to intercept an built-in Outlook dialog and display instead a custom .NET form.

Outlook Forms Step by Step -- Create a check request form and make it available on the company intranet with this 16-part illustrated guide.

Duplicate Email Remover for Outlook -- This add-in can find duplicated messages by looking at the text in the message body, headers, subject and attachments.

Reply to an email with a template -- Template Phrases add-in for Outlook allows inserting frequently-typed text into an e-mail message in a click.

Making a Custom Ribbon Appear Only for a Custom Outlook Form -- Norm Estabrook from the VSTO team shows how to make custom tabs, groups and controls appear only in cases where the user opens a custom form in Outlook.

Outlook Context Menus and Creating a Meeting from an Email -- Short video demonstrating how to create a context menu command for sending a meeting request to recipients of an email message. Note: The Inspector wrapper class is extraneous and overcomplicates the project.

How to get the IWin32Window for Outlook -- This C# class from Helmut Obertanner could be used to pass the Outlook as parent to .Net Forms and Messageboxes to prevent those UI elements from being hidden by Outlook windows.

Additional custom panel in Microsoft Outlook -- Lukas Neumann uses Windows API techniques to hack the Outlook user interface and add a custom panel in the Explorer window.

Hot Code Samples

Save and remove attachments from email items...
Create task from e-mail message (revised)...
OL2007: Run all rules against inbox
C# AddIn sample: InspectorWrapper & CommandBar...
Reply with Attachments
Send Word document as message
Insert user signature with VBA
Set color label on appointment
Set email account signature in Outlook 2003...

OutlookCode RSS Feeds

All content

Outlook developer news

New Outlook developer resources forums code samples articles