[英]How do I repurpose the context menu for reply?
I have an Explorer.xml, where I found the right-click reply control to be in idMso "ContextMenuMailItem"我有一个 Explorer.xml,在那里我发现右键单击回复控件位于 idMso“ContextMenuMailItem”中
<contextMenu idMso="ContextMenuMailItem">
<button idMso="Reply" onAction="Reply_RightClick"/>
</contextMenu>
However, when I try to set an onAction to it, the function is not being called.但是,当我尝试为其设置 onAction 时,并未调用该函数。
public void Reply_RightClick(Office.IRibbonControl control)
{
//do something
}
I know the .cs file is properly set up because I have custom buttons that are properly triggering its respective function, and I know that reply button is the one I want because when I toggle visible/enable to false, it gets appropriately hidden/disabled.我知道 .cs 文件设置正确,因为我有正确触发其各自功能的自定义按钮,而且我知道回复按钮是我想要的,因为当我将可见/启用切换为 false 时,它会被适当地隐藏/禁用. How can I intercept this reply?
我怎样才能截获这个回复? Please help!
请帮忙!
If it ever proves helpful to someone else, I managed to find a workaround to this!
如果证明对其他人有帮助,我设法找到了解决方法!
First, hide the original reply button on the context menu.首先,隐藏上下文菜单上的原始回复按钮。
<contextMenu idMso="ContextMenuMailItem">
<button idMso="Reply" visible="false"/>
</contextMenu>
Then, add a custom reply button to the context menu at the same spot where you hid the reply button, with the reply icon然后,在隐藏回复按钮的同一位置的上下文菜单中添加一个自定义回复按钮,并带有回复图标
<button id="Custom_Reply" onAction="reply_click" label="Reply" insertBeforeMso="MarkAsRead" imageMso="Reply"/>
<menuSeparator id="Separator" insertBeforeMso="MarkAsRead/>
And after that, you will be able to do what you need to your reply button之后,您将能够对回复按钮执行所需的操作
public void reply_click(Office.IRibbonControl control)
{
if(control.Context is Outlook.Selection)
{
Outlook.Selection item = control.Context as Outlook.Selection);
if(item[1] is Outlook.MailItem mailItem)
{
mailItem = item[1] as Outlook.MailItem;
//do stuff to your mailitem
//then do a .reply and display the repurposed mailitem
Outlook.MailItem replyMail = mailItem.Reply();
replyMail.Display();
//don't forget to release your comobjects!
if(replyMail != null) Marshal.ReleaseComObject(replyMail);
if(mailItem != null) Marshal.ReleaseComObject(mailItem);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.