How to get the messageclass of a selected item in Outlook

H

Hans Schmidt

Hello,

i'm trying to recognize in my COM-Addin if a mail or appointment
object is selected. In both cases i will add a commandbar. Therefore i
implemented the OnNewInspector event and the OnSelectionChange event.

public partial class ThisAddIn
{
Outlook.Application applicationObject;
private Outlook.Inspectors _inspectors;
Outlook.Explorer explorer;
Outlook.Selection selection;

private void ThisAddIn_Startup(object sender, System.EventArgs
e)
{
_inspectors = Application.Inspectors;
_inspectors.NewInspector += new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler
(ThisApplication_NewWindowOpen);
explorer = Application.ActiveExplorer();
explorer.SelectionChange += new
Outlook.ExplorerEvents_10_SelectionChangeEventHandler(
Explorer_SelectionChange);
}

void ThisApplication_NewWindowOpen
(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{

}

void Explorer_SelectionChange()
{

}

private void ThisAddIn_Shutdown(object sender,
System.EventArgs e)
{
}

#region Von VSTO generierter Code

/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor
geändert werden.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler
(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler
(ThisAddIn_Shutdown);
}

#endregion
}

I tried different things with Outlook.Selection selection; but never
came to a solution.
In several vb examples the developers used selection.item but i can't
find that in C#

has got anybody a solution?


Thanks and greets Hans
 
K

Ken Slovak - [MVP - Outlook]

You would check Selection.Count to see how many items are selected. In C#
you would use selection[1]...selection[n] to access Selection members.




Hello,

i'm trying to recognize in my COM-Addin if a mail or appointment
object is selected. In both cases i will add a commandbar. Therefore i
implemented the OnNewInspector event and the OnSelectionChange event.

public partial class ThisAddIn
{
Outlook.Application applicationObject;
private Outlook.Inspectors _inspectors;
Outlook.Explorer explorer;
Outlook.Selection selection;

private void ThisAddIn_Startup(object sender, System.EventArgs
e)
{
_inspectors = Application.Inspectors;
_inspectors.NewInspector += new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler
(ThisApplication_NewWindowOpen);
explorer = Application.ActiveExplorer();
explorer.SelectionChange += new
Outlook.ExplorerEvents_10_SelectionChangeEventHandler(
Explorer_SelectionChange);
}

void ThisApplication_NewWindowOpen
(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{

}

void Explorer_SelectionChange()
{

}

private void ThisAddIn_Shutdown(object sender,
System.EventArgs e)
{
}

#region Von VSTO generierter Code

/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor
geändert werden.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler
(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler
(ThisAddIn_Shutdown);
}

#endregion
}

I tried different things with Outlook.Selection selection; but never
came to a solution.
In several vb examples the developers used selection.item but i can't
find that in C#

has got anybody a solution?


Thanks and greets Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top