C# MailItem.HtmlBody引发未实现的异常

C# MailItem.HtmlBody引发未实现的异常,c#,outlook,vsto,outlook-addin,mailitem,C#,Outlook,Vsto,Outlook Addin,Mailitem,我有一个功能区按钮,可以通过修改邮件项目对象(基于其中的收件人),将文本插入outlook检查器。单击时调用的方法如下所示: public async void OnTemplateClick(Office.IRibbonControl control) { var templateId = control.Tag; var template = templates.GetTemplateById(templateId);

我有一个功能区按钮,可以通过修改邮件项目对象(基于其中的收件人),将文本插入outlook检查器。单击时调用的方法如下所示:

public async void OnTemplateClick(Office.IRibbonControl control)
        {
            var templateId = control.Tag;
            var template = templates.GetTemplateById(templateId);
            await templateUi.SetTemplate(control.Context, template);
        }
SetTemplate方法如下所示:

public async Task SetTemplate(object window, Template template, 
            SynchronizationContext uiThread = null)
{
Outlook.MailItem currentMailItem = null;
            Outlook.Recipients olRecps = null;
            Outlook.Recipient recp = null;
            Outlook.AddressEntry addEntry = null;
            try
            {
                currentMailItem = GetMailItem(window);
                olRecps = currentMailItem.Recipients;
                var recipType = Outlook.OlMailRecipientType.olTo;
                var recps = from r in olRecps.Cast<Outlook.Recipient>()
                            where r.Type == (int)recipType
                            select r;
                var numRecps = recps.Count();

                var oldBodyHtml = currentMailItem.HTMLBody;
               ...
这个错误并非总是发生,而且很难重现,因此我们主要在应用程序日志中看到它。我想知道是什么导致了这个错误?我假设这与这个异步调用的时间有关,这意味着MailItem消息没有完全形成


谢谢

Outlook对象模型不能在辅助线程上使用。Outlook 2016在检测到此类呼叫时将立即引发错误。在旧版本的Outlook中,调用可能会意外失败


如果必须使用辅助线程,则只能选择(C++或Delphi)或(其对象系列)。

当然,不要使用async/await。
System.Runtime.InteropServices.COMException (0x8E604001): Not implemented.
   at Microsoft.Office.Interop.Outlook._MailItem.get_HTMLBody()