我一直在使用Outlook加载项,我需要能够捕获用户收到会议请求时显示的三个按钮(接受,拒绝和建议新时间)的点击事件。
我在网上浏览过,我认为这些可以用.xml处理,但出于某种原因,我似乎无法解决我的事件。
似乎以下链接提供了我的问题的答案,这是我正在遵循的策略。
我已将.xml功能区项添加到项目中:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<commands>
<command idMso="DeclineInvitationNoResponse" onAction="Decline"/>
<command idMso="AcceptInvitationNoResponse" onAction="Accept"/>
</commands>
</customUI>
在功能区的.cs文件中我有:
namespace EquipmentScheduler
{
[ComVisible(true)]
public class AlterMeetingResponse : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
public AlterMeetingResponse()
{
}
#region IRibbonExtensibility Members
public string GetCustomUI(string ribbonID)
{
return GetResourceText("EquipmentScheduler.AlterMeetingResponse.xml");
}
#endregion
#region Ribbon Callbacks
//Create callback methods here. For more information about adding callback methods, select the Ribbon XML item in Solution Explorer and then press F1
public void Decline(Office.IRibbonControl Control, bool Cancel)
{
Debug.Print("Decline button hit");
}
public void Accept(Office.IRibbonControl Control, bool Cancel)
{
Debug.Print("Accept button hit");
}
}
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
}
#endregion
#region Helpers
private static string GetResourceText(string resourceName)
{
Assembly asm = Assembly.GetExecutingAssembly();
string[] resourceNames = asm.GetManifestResourceNames();
for (int i = 0; i < resourceNames.Length; ++i)
{
if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
{
using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
{
if (resourceReader != null)
{
return resourceReader.ReadToEnd();
}
}
}
}
return null;
}
#endregion
}
}
我还在ThisAddIn.cs
中添加了以下功能protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new AlterMeetingResponse();
}
但是,我还没有设法让Accept / Reject例程中的代码运行。
非常感谢任何帮助。
由于
本杰明比格斯