4

Getting a currently open new email message (when un-docked from the main Outlook window) requires the following code:

Outlook.Application oApp = new Outlook.Application();
Outlook.Inspector inspector = oApp.ActiveInspector();
item = inspector.CurrentItem;
Outlook.MailItem oMsg = item as Outlook.MailItem;

How do you do this when the new message is docked within the main window of Outlook? This happens when the user clicks the Reply button within the message they are currently viewing.

Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
  • I found the solution...... Outlook.Application oApp = new Outlook.Application(); Outlook.MailItem oMsg = explorer.GetType().InvokeMember("ActiveInlineResponse", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, null, explorer, null) as Outlook.MailItem; That will get the docked reply message as an Outlook.MailItem – user3777445 Jun 26 '14 at 04:56

1 Answers1

2

If you want to return the new message as an object (like Outlook.MailItem), you should try this:

Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = explorer.GetType().InvokeMember("ActiveInlineResponse",
    System.Reflection.BindingFlags.GetProperty |
    System.Reflection.BindingFlags.Instance |
    System.Reflection.BindingFlags.Public, null, explorer, null) as Outlook.MailItem;

You should be able to attach a file to the currently docked Outlook message as required.

eggy
  • 2,836
  • 3
  • 23
  • 37