Reputation: 60
I have a simple Problem. I have a litte Outlook AddIn. Now I want to add a Ribbon to it, for manually executing a Method.
public partial class ThisAddIn
{
Outlook.NameSpace outlookNameSpace;
Outlook.MAPIFolder inbox;
Outlook.Items items;
Outlook.MAPIFolder destinationFolder = null;
Outlook.MAPIFolder rootFolder = null;
//Outlook.Folders rootFolderFolders = null;
Outlook.Store store = null;
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new MyRibbon();
}
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookNameSpace = this.Application.GetNamespace("MAPI");
inbox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
items = inbox.Items;
items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
}
public void RibbonAction()
{
MessageBox.Show("Action Found Class");
Outlook.Explorer currentExplorer = null;
currentExplorer = this.Application.ActiveExplorer();
}
And MyRibbon.cs
public class MyRibbon : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
public MyRibbon()
{
}
public void OnTextButton(Office.IRibbonControl control)
{
thisAddIn.RibbonAction();
}
I want to iterate through the the selected Items in the Outlook explorer. It seems I can not do this in MyRibbon, so I want to implement the Method in thisAddIn. But Visual Studio let me not do this.
Upvotes: 0
Views: 1091
Reputation: 2147
Since it looks like you don't use the function RibbonAction()
in the class ThisAddIn
, delete it here and insert the function directly in the class MyRibbon
.
To get the ActiveExplorer
somewhere else as in ThisAddIn
class you can use the following code:
Outlook.Explorer activeExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
Upvotes: 1