index > Visual Studio Tools for Office > Outlook: Opening the Insert File dialog

Outlook: Opening the Insert File dialog

I'm writing some small samples to illustrate different VSTO concepts. One is an Outlook add-in that gives you a second chance to add an attachment if the string "attach" appears in the body of the message. If the user chooses to cancel the send and add an attachment, I'd like the Insert File dialog box to open automatically. I have code that's working, but I'm wondering if there's a better way:

                ' Execute the Insert File command button (ID = 777)
                myMailItem.GetInspector.CommandBars.FindControl(, 777).Execute()

This is based on a sample of Sue Mosher's on OutlookCode.com but that sample uses 1079 as the ID. That didn't work (maybe different version of Outlook?) so I used OutlookSpy to find the 777 number. Are there constants that I'm not aware of to make this more readable/robust? Or a better way altogether?

 

Jan F

Jan,

There is no way to get a direct reference to the add attachment dialog box to then control its behavior. Going through the CommandBars as Sue suggests is the only way that I know of. For the most part, the IDs should be stable. This is also true for localized versions of the software. That said, I cannot confirm that all of them are constant.

I would feel at ease using them in a sample, though.

That said, another technique you can try is to provide your own custom form for selecting the attachment. It's very easy to do (and I know you know how to do that stuff in your sleep, Jan ). Using a simple winform, a filebrowser dialog, a text box, dropdown box, and two buttons, and you have most of the functionality right there.

I'll consider this answered, but you can re-post if you feel there is something I've overlooked.

John.




http://blogs.msdn.com/johnrdurant
John R. Durant - MSFT
Thanks, John. I just wanted to make sure I wasn't missing anything obvious. I'll stick with the the CommandBars technique for Chapter 1, but you've given me a good idea for an enhancement in a later chapter!
--jan
Jan F
reply 3

You can use google to search for other answers

 

More Articles

• Do you have to have Office installed?
• row count and column count of excel file in C#
• Exporting HTML Data to PowerPoint. Is there a windows component t...
• Double-click on Windows Form control opening VBA Editor
• C# with Excel - are ranges with letters no longer usable, like &q...
• Getting Excel install folder
• Capturing Out of office event in Outlook 2003
• Outlook Add-in Setup Issues
• Outlook addin not installing the addin through set up
• Enable/disable popups in main menu
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• How to edit the Oultlook default folders
• VS2005 errors after upgrade from VSTO v3
• Access Developer Extension
• Microsoft Access and Outlook Integration
• Workaround need to open a customized Wor
• Excel Data Binding question
• Document Level Customization - Excel
• Need to get to Excel.Application referen
• Managed Code Extension and Active Docume
• How do i Hide fields so that they don't
• Using AxSpreadsheet
• office 12 images
• Does Microsoft Office InfoPath 2003 Tool
• Cells.NumberFormat - not standart (from
• VSTO Document From Windows Application

Hot Articles

• Creating Excel Workbooks - ISSUE
• String parsing in VBA 6.3
• Question on VSTO for Exchange
• New to this - how to embed in outlook?
• argument display and description for Use
• Drag and drop data item on to MS Word
• Accessing Excel Files in different versi
• VSTO2005 Excel- Insert Comment into cell
• Running Word Merge client side with a do
• Do I have VSTO?
• Preventing other applications to attach
• Trouble installing VSTO with Word 2007 B
• VSTO 2005 COM Add-In Word
• How can i refer DLL created in .NET in V
• Managed Code Extension and Active Docume

Recommend Articles

• XMI - Tool compatibility
• vsto2005
• Event of PowerPoint.Application confict
• Excel & C/C++
• How to Convert an Excel Sheet to XML for
• How to copy part of Excel to another Exc
• TaskPane + Word.xml + beta2
• VSTO-2 (2003) Word Template code-behind
• Basic setup project for VSTO includes pr
• How to pass parameters to a Word VSTO so
• show excel chart on a form in excel 2000.
• newbie to vsto with problems
• Deploying outlook add-in
• How do you get the handle to the main Wo
• Type vbproj not supported by Visual Stud