[英]Created OutLook VSTO Add-In Project in VisualStudio 2019 , how to show a image in place of default ribbon text?
I am trying to implement - Read email panel using a button with custom image using "outlook VSTO Add-In".我正在尝试实现 - 使用“outlook VSTO 插件”使用带有自定义图像的按钮读取 email 面板。
With below code, I am able to add a "Read a Loud Button" to home toolbar but my requirement is to add a button with custom image to Read email window, Could you please suggest how to achieve this behavior?使用下面的代码,我可以在主页工具栏中添加一个“读取响亮按钮”,但我的要求是添加一个带有自定义图像的按钮来读取 email window,您能否建议如何实现此行为?
Thanks in advance.提前致谢。
private Office.CommandBar newToolBar;
private Office.CommandBarButton newToolBarButton;
private System.Speech.Synthesis.SpeechSynthesizer syn = new System.Speech.Synthesis.SpeechSynthesizer();
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
// Add new Toolbar, if not exist
if (newToolBar == null)
{
newToolBar = Application.ActiveExplorer().CommandBars.Add("MyToolBar", Office.MsoBarPosition.msoBarTop, false, true);
// Add Button to Toolbar
newToolBarButton = (Office.CommandBarButton)newToolBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
newToolBarButton.Caption = "Stop Voice";
newToolBarButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(newToolBarButton_Click);
newToolBar.Visible = true;
}
Application.NewMailEx += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx);
}
// New Mail Event Handler
void Application_NewMailEx(string EntryIDCollection)
{
try
{
if (((Outlook.MailItem)this.Application.Session.GetItemFromID(EntryIDCollection, missing)).UnRead)
{
var body = ((Outlook.MailItem)this.Application.Session.GetItemFromID(EntryIDCollection, missing)).Body;
var subject = ((Outlook.MailItem)this.Application.Session.GetItemFromID(EntryIDCollection, missing)).Subject;
var sender = ((Outlook.MailItem)this.Application.Session.GetItemFromID(EntryIDCollection, missing)).SenderName;
syn.SpeakAsync("Mail From " + sender + "Subject is " + subject + body);
}
}
catch
{
}
}
void newToolBarButton_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
syn.SpeakAsyncCancelAll();
}
Command bars were deprecated.命令栏已弃用。 Instead, you need to use the Fluent UI (aka Ribbon UI).相反,您需要使用 Fluent UI(又名 Ribbon UI)。 The following articles explain how to create a custom UI for the ribbon:以下文章介绍了如何为功能区创建自定义 UI:
The Fluent UI is described in depth in the following series of articles: Fluent UI 在以下系列文章中有深入介绍:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.