【发布时间】:2016-06-21 13:48:31
【问题描述】:
我有一个功能区按钮,通过根据其中的收件人修改 MailItem 对象,将文本插入到 Outlook Inspector 中。点击时调用的方法如下所示:
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;
...
现在,有时,获取 HTMLBody 的最后一行会引发以下错误:
System.Runtime.InteropServices.COMException (0x8E604001): Not implemented.
at Microsoft.Office.Interop.Outlook._MailItem.get_HTMLBody()
这个错误不会一直发生,而且很难重现,所以我们大多在应用程序日志中看到它。我想知道什么可能导致这个错误?我认为这与此异步调用的时间有关,这意味着 MailItem 消息没有完全形成?
谢谢!
【问题讨论】:
标签: c# outlook vsto outlook-addin mailitem