简体   繁体   English

如何避免在Outllook插件的自定义选项卡中单击按钮时完全刷新

[英]How to avoid complete refresh on button click in custom tab of Outllook Plugin

I am new to Add in development . 我是新加入开发人员。 I have started working on Outlook addin development using VSTO . 我已经开始使用VSTO开发Outlook插件

I have added a new tab and placed a buttton in that tab . 添加了一个新标签,并在该标签中放置了一个buttton When ever i click on button , i am sending an email . 每当我单击按钮时,我都会发送电子邮件

It is working fine . 运行良好 But , the problem is when ever i click on button , it is flashing entire outlook screen that is complete reload. 但是,问题是,当我单击按钮时,它会闪烁整个Outlook屏幕,并重新加载。

How to avoid this and do it gracefully , so that page does not get reloaded. 如何避免这种情况并优雅地进行,以免重新加载该页面。

Here , is my code for your reference : 这是我的代码供您参考:

public partial class Ribbon1
    {
        private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
        {

        }

        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            SendAutoNotification();
        }

        public void SendAutoNotification()
        {
            Outlook.MailItem mailItem = (Outlook.MailItem)
                Globals.AutoMailer.Application.CreateItem(Outlook.OlItemType.olMailItem);
            mailItem.Subject = "AutoGeneratedEmail";
            mailItem.To = "xxx.xxx@xxx.com";
            mailItem.Body = "This is just for test purpose. This is an auto generated email from outlook adddin";
            mailItem.Importance = Outlook.OlImportance.olImportanceLow;
            mailItem.Display(false);
            ((Outlook._MailItem)mailItem).Send();
        }
    }

There is no need to use the Display method of the MailItem class in the code: 不需要在代码中使用MailItem类的Display方法:

public void SendAutoNotification()
    {
        Outlook.MailItem mailItem = (Outlook.MailItem)
            Globals.AutoMailer.Application.CreateItem(Outlook.OlItemType.olMailItem);
        mailItem.Subject = "AutoGeneratedEmail";
        mailItem.To = "xxx.xxx@xxx.com";
        mailItem.Body = "This is just for test purpose. This is an auto generated email from outlook adddin";
        mailItem.Importance = Outlook.OlImportance.olImportanceLow;
        ((Outlook._MailItem)mailItem).Send();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM