'Accessing a Document being edited in a Outlook reading pane
I have written a simple VSTO addon that inserts a hyperlink into an e-mail when user clicks on a ribbon bar button. Here is a code sample:
private void button1_Click(object sender, RibbonControlEventArgs e)
{
var context = e.Control.Context as Inspector;
if (context != null)
{
if (context.IsWordMail())
{
var doc = context.WordEditor as Document;
if (doc != null)
{
var sel = doc.Windows[1].Selection;
doc.Hyperlinks.Add(sel.Range, "http://www.google.com", "", "", "Google", "");
}
}
}
else if (e.Control.Context is Explorer)
{
Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
if (explorer.Selection.Count == 1)
{
Microsoft.Office.Interop.Outlook.Selection itemSelection = explorer.Selection;
var item = itemSelection[1] as MailItem;
// get the instance of WordEditor in a reading pane?
}
}
}
This works well when the e-mail is being edited in a separate windows (e.Control.Context is Inspector).
If the messsage is being replied to/forwarded and the reading pane is turned on, the editor is displayed inline in the reading pane (e.Control.Context is Explorer).
I can not figure out how to get the instance of the Document in this case. I can access the item selected in the Explorer but I cannot figure how to access the Document editor being displayed in a reading pane.
If I 'pop out' the editor to a separate window, it works fine (context changes to Inspector).
Is there a way to access a e-mail document which is edited directly inside reading pane?
With great help from Dmitry who pointed me in right direction I found out that there is a property in a Explorer class: Explorer.ActiveInlineResponseWordEditor which gives you editor displayed inline.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
